nginx.conf 文件配置
#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;
}
}
}
原文地址:https://blog.csdn.net/code12313/article/details/135465245
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!