Skip to content

Instantly share code, notes, and snippets.

@JohnnyCurran
Created June 19, 2022 20:46
Show Gist options
  • Save JohnnyCurran/c2fbd2615b6257b1d2f785d797aa43fc to your computer and use it in GitHub Desktop.
Save JohnnyCurran/c2fbd2615b6257b1d2f785d797aa43fc to your computer and use it in GitHub Desktop.
# /etc/nginx/sites-available/default
# Phoenix LiveView Nginx configuration - Reverse proxy to Phoenix app running on localhost
# All lines with # managed by certbot are placed automatically by [certbot](https://certbot.eff.org)
# Replace $YOUR_SITE_NAME with your url host unless line is followed with # managed by Certbot
# Default server configuration
#
server {
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/$YOUR_SITE_NAME/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/$YOUR_SITE_NAME/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
server_name $YOUR_SITE_NAME; # Set your www.mySiteName.com mySiteName.com here
location / {
proxy_pass http://127.0.0.1:4000;
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 X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
location /live {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
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 X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass http://127.0.0.1:4000/live;
proxy_read_timeout 6000s; # raise the proxy timeout for the websocke
}
}
server {
if ($host = $YOUR_SITE_URL) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = $YOUR_SITE_URL) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment