Skip to content

Instantly share code, notes, and snippets.

@yarkovaleksei
Forked from LopatkinEvgeniy/nodejs proxy
Created February 10, 2017 20:33
Show Gist options
  • Save yarkovaleksei/95e53615a1614f0ecae61d52c0485ec5 to your computer and use it in GitHub Desktop.
Save yarkovaleksei/95e53615a1614f0ecae61d52c0485ec5 to your computer and use it in GitHub Desktop.
nginx
# Простой пример
server {
listen 80;
server_name localhost;
charset koi8-r;
location / {
root /var/www/nodejs/public;
index index.html;
try_files $uri $uri/ @backend;
}
location @backend {
proxy_pass http://localhost:9001;
proxy_http_version 1.1;
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_connect_timeout 20;
}
}
# Рабочий пример
server {
listen 80 default_server;
listen 443 ssl;
client_max_body_size 1G;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
root /srv/raidix/public;
index index.html;
error_log /var/log/nginx/error;
access_log /var/log/nginx/access;
location / {
try_files $uri $uri/ @api;
}
location @api {
proxy_pass http://localhost:9001;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /websockify {
proxy_pass http://localhost:8787/websockify;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment