Skip to content

Instantly share code, notes, and snippets.

@jaigouk
Forked from ziazek/deploy_phoenix
Created September 25, 2017 18:18
Show Gist options
  • Save jaigouk/38344d4a3b60a5262f01af6d37f68b1b to your computer and use it in GitHub Desktop.
Save jaigouk/38344d4a3b60a5262f01af6d37f68b1b to your computer and use it in GitHub Desktop.
nginx configuration
upstream deploy_phoenix {
server 127.0.0.1:8888;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# REDIRECT HTTP www.example.com to HTTPS example.com
server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
# REDIRECT HTTP example.com to HTTPS example.com
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
# REDIRECT HTTPS www.example.com to HTTPS example.com
server {
listen 443 ssl http2;
server_name www.example.com;
# INCLUDE SSL SNIPPETS
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
# INCLUDE SSL SNIPPETS
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
# for LetsEncrypt certbot
location /.well-known {
alias /home/deploy/certbot/.well-known;
}
location / {
try_files $uri @proxy;
}
location @proxy {
include proxy_params;
proxy_redirect off;
proxy_pass http://deploy_phoenix;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment