Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

897 support heroku redis tls connection #966

Merged
merged 4 commits into from
Jun 17, 2023

Conversation

Workhqd
Copy link
Collaborator

@Workhqd Workhqd commented May 1, 2023

This pr is to solve the issue 897 support heroku redis tls connection.
This branch has been update based on the new version. I have rebase rebase this branch on top of master.
I have done two tests.

First test: test the job could be enqueue or not
d4a58f798121dbbe0d5be187f40332f

Second test: open the democracylab website, login the test account, and then send the email to the volunteer. If the job is enqueued correctly, the rqworker could handle the job. And finally, you could see the email in the rqworker windows rather than the windows you ran python manage.py runserver.
b95b0c915448f9f646d6ec6901e4fcd

First test's steps:

  1. sudo apt install redis-server
  2. sudo apt install openssl
  3. sudo mkdir /etc/redis/ssl
  4. Generate the private key and self-signed certificate using the following command:
    sudo openssl req -x509 -newkey rsa:4096 -keyout /etc/redis/ssl/redis.key -out /etc/redis/ssl/redis.crt -days 365 -nodes
  5. Edit the Redis configuration file: sudo nano /etc/redis/redis.conf
    Add: port 6379
    tls-port 6380
    tls-cert-file /etc/redis/ssl/redis.crt
    tls-key-file /etc/redis/ssl/redis.key
    tls-ca-cert-file /etc/redis/ssl/redis.crt
  6. Add two environment variables in the
    export REDIS_ENABLED='True'
    export REDIS_URL='rediss://localhost:6380/0?ssl_cert_reqs=none&ssl_ca_certs=/etc/redis/ssl/redis.crt'
  7. write a test.py( I have deleted it from this branch)
  8. restart the vm
    open a window and run:
    source ~/Desktop/democracylab_environment_variables.sh
    source ~/git/virtualenv/bin/activate
    sudo -E redis-server --tls-port 6380 --tls-cert-file /etc/redis/ssl/redis.crt --tls-key-file /etc/redis/ssl/redis.key --tls-ca-cert-file /etc/redis/ssl/redis.crt --tls-auth-clients no --tls-replication yes
    open another window and run:
    source ~/Desktop/democracylab_environment_variables.sh
    source ~/git/virtualenv/bin/activate
    cd ~/git/CivicTechExchange
    python manage.py rqworker
    open third window and run:
    source ~/Desktop/democracylab_environment_variables.sh
    source ~/git/virtualenv/bin/activate
    python manage.py test

Second test's steps:
1-5 steps in first test's step
6. Add an environment variable:
export REDIS_ENABLED='True'
7. restart the vm
open a window and run:
source ~/Desktop/democracylab_environment_variables.sh
source ~/git/virtualenv/bin/activate
sudo -E redis-server --tls-port 6380 --tls-cert-file /etc/redis/ssl/redis.crt --tls-key-file /etc/redis/ssl/redis.key --tls-ca-cert-file /etc/redis/ssl/redis.crt --tls-auth-clients no --tls-replication yes
open another window and run:
source ~/Desktop/democracylab_environment_variables.sh
source ~/git/virtualenv/bin/activate
cd ~/git/CivicTechExchange
python manage.py rqworker
open third window and run:
source ~/Desktop/democracylab_environment_variables.sh
source ~/git/virtualenv/bin/activate
python manage.py runserver
8. open the website and send an email(contact the volunteer)

@Workhqd Workhqd requested a review from marlonkeating May 6, 2023 18:56
@Workhqd Workhqd linked an issue May 6, 2023 that may be closed by this pull request
@marlonkeating marlonkeating temporarily deployed to democracy-lab-prod-mirror May 23, 2023 03:55 Inactive
@marlonkeating marlonkeating temporarily deployed to democracy-lab-prod-mirror June 15, 2023 23:47 Inactive
@marlonkeating marlonkeating merged commit a8c5029 into master Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support heroku redis TLS connection
2 participants