Skip to content

Instantly share code, notes, and snippets.

@ecpplus
Last active July 11, 2018 09:02
Show Gist options
  • Save ecpplus/c36ee913cc2cbfefbd904e9defb48d6d to your computer and use it in GitHub Desktop.
Save ecpplus/c36ee913cc2cbfefbd904e9defb48d6d to your computer and use it in GitHub Desktop.
nginx.conf example for Phoenix Framework
upstream phoenix_server {
server localhost:4001;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
server_name chat.ecpplus.net;
ssl on;
# something for TLS
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains;';
rewrite_log on;
root /webroot/to/phoenix/priv/static;
location /socket {
proxy_pass http://phoenix_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
break;
}
location / {
location ~* \.(css|js)(\?.*)?$ {
expires 1y;
add_header Cache-Control public;
gzip on;
gzip_vary on;
gzip_static on;
break;
}
location ~* \.(png|ico|gif|jpe?g)(\?.*)?$ {
expires 1w;
add_header Cache-Control public;
break;
}
if (!-f $request_filename) {
proxy_pass http://phoenix_server;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment