How to use letsencrypt with Phoenix and Nginx?

Hello,
I am trying to figure out a way to use let’s encrypt SSL certificate with the phoenix by putting it into file structure ( for now I don’t care about updation problem ).
It would be helpful if someone can guide me with the nginx configuration as there are a bit confusing samples for the new comers :sweat_smile:.
Please explain how can I redirect the port 443 (https, I believe) to phoenix port 4000.
Thanks for the help :slightly_smiling_face:

1 Like

Well I use certbot’s nginx plugin, and it automatically added these to the domains it managed:

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/the_site/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/the_site/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

But it was all automatic. Just setup Phoenix behind nginx as normal, then use something like certbot to do the rest for you. :slight_smile:

1 Like

This has a lot of info:
https://medium.com/@zek/secure-your-phoenix-app-with-free-ssl-48ac749c17d7

5 Likes

think these articles should help you get there:

especially this one: (that is already linked by @amnu3387)

https://medium.com/@zek/secure-your-phoenix-app-with-free-ssl-48ac749c17d7

4 Likes

Are you looking for the documentation on proxy_pass?

For my deployments I also use the following settings for the forwarding:

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
3 Likes

Wow,
I mean thanks guys, it’s really awesome to see that this many experienced person came to save a beginner, I am highly thankful to u all.

With this I believe I will have a good start and learning of concept and I’ll post any doubt in thread here if I got any.:sweat_smile:
( Sorry for off topic reply).

4 Likes