Last active
November 6, 2018 20:41
-
-
Save marinho10/b444fa35f46d575da8ddff1cc2c54c7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream phoenix { | |
server 127.0.0.1:4000 max_fails=5 fail_timeout=60s; | |
} | |
server { | |
root /var/www/html; | |
# Add index.php to the list if you are using PHP | |
index index.html index.htm index.nginx-debian.html; | |
server_name <server_name>; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
} | |
location ~* /api/(?<path>.*$) { | |
#set $upstream "http://127.0.0.1:4000/api/"; | |
allow all; | |
proxy_http_version 1.1; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Cluster-Client-Ip $remote_addr; | |
# The Important Websocket Bits! | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
#proxy_pass $upstream$path$is_args$args; | |
proxy_pass http://phoenix; | |
} | |
location ~* /socket/(?<path>.*$) { | |
allow all; | |
proxy_http_version 1.1; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Cluster-Client-Ip $remote_addr; | |
proxy_redirect off; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_pass http://phoenix; | |
} | |
if ($scheme = "ws") { | |
return 301 wss://$host$request_uri; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/<server_name>/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/<server_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 { | |
if ($host = <server_name>) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
server_name <server_name>; | |
return 404; # managed by Certbot | |
} | |
server { | |
if ($host = <server_name>) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
server_name <server_name>; | |
listen 80; | |
return 404; # managed by Certbot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment