Skip to content

Instantly share code, notes, and snippets.

@ivlevdenis
Created January 31, 2017 11:29
Show Gist options
  • Save ivlevdenis/73f29008f25f0210bd749ad653ece9bc to your computer and use it in GitHub Desktop.
Save ivlevdenis/73f29008f25f0210bd749ad653ece9bc to your computer and use it in GitHub Desktop.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 127.0.0.1:8888;
}
upstream backend_PROJ {
server unix:///opt/PROJ/socket;
}
server {
listen 80;
listen [::]:80;
server_name PROJ.local;
client_max_body_size 100m;
location ^~ /static {
alias /opt/PROJ/static;
}
location ^~ /media {
alias /opt/PROJ/media;
}
location ~ ^/(admin|api) {
uwsgi_pass backend_PROJ;
include uwsgi_params;
}
location ~ ^/(binding|stream) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
root /opt/PROJ/front;
error_page 405 =200 $uri;
index index.html;
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment