#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - remote_user \[time_local] "$request" '
'$status body_bytes_sent "http_referer" '
'"http_user_agent" "http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#负载地址
upstream gateway {
server IP1;
server IP2;
}
server {
listen 8010;
server_name localhost;
#charset koi8-r;
server_tokens off;
add_header X-Frame-Options DENY;
add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval' blob: data: ;";
add_header X-Xss-Protection "1;mode=block";
add_header X-Content-Type-Options nosniff;
#access_log logs/host.access.log main;
###日志按天分割
if ($time_iso8601 ~ '(\d{4}-\d{2}-\d{2})'){
set $ttt $1;
}
limit_req zone=allips burst=2 nodelay;
access_log logs/access.$ttt.log;
error_log logs/error.log;
###日志结束
location / {
root /app/code; #项目路径
index index.html index.htm;
}
location ^~/api/ {
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_set_header X-NginX-Proxy true;
proxy_pass http://gateway/;
}
#error_page 404 /404.html;
redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}