forked from thx/rap2-delos
-
Notifications
You must be signed in to change notification settings - Fork 7
Nginx配置
shine0565 edited this page Sep 21, 2018
·
7 revisions
假设我们有两台静态服务器,10.10.10.1,10.10.10.2,一套k8s集群,loadbalance暴露地址10.10.20.1:8080,一台nginx,10.10.10.10。
module.exports = { serve: 'http://10.10.10.10:38080', keys: ['some secret hurr'], session: { key: 'koa:sess' } }
##Nginx
` user root; worker_processes 4; events { worker_connections 1024; }
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 30m;
upstream front {
server 10.10.10.1:80;
server 10.10.10.2:80;
}
server {
listen 80;
server_name localhost;
location ~ /nginx_status {
stub_status on;
access_log on;
}
#access_log logs/host.access.log main
location / {
# 404
proxy_intercept_error on;
proxy_pass http://front;
proxy_set_header Host $host
proxy_set_header X-Real-IP $remote_addr;
root /var/www/html;
# 404
try_files $uri $uri @router;
index index.html index.htm;
}
#404
location @router {
rewrite ^.*$ /index.html last;
}
}
server {
listen 38080;
server_name localhost;
location / {
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_set_header X-Nginx-Proxy true;
proxy_set_header Connection "";
proxy_pass http://10.10.20.1:8080/;
}
}
}`