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;

}

}

}

相关推荐
liebe1*116 分钟前
第七章 防火墙地址转换
运维·服务器·网络
好好学操作系统22 分钟前
autodl 保存 数据 跨区
linux·运维·服务器
dbitc24 分钟前
WIN11把WSL2移动安装目录
linux·运维·ubuntu·wsl
旺仔Sec25 分钟前
2026年度河北省职业院校技能竞赛“Web技术”(高职组)赛项竞赛任务
运维·服务器·前端
BullSmall1 小时前
linux 根据端口查看进程
linux·运维·服务器
嘻哈baby1 小时前
Ansible自动化运维入门:从手工到批量部署
运维·自动化·ansible
Hard but lovely1 小时前
linux:----进程守护化(Daemon)&&会话的原理
linux·运维·服务器
吕了了2 小时前
86 [深度解析] 系统的产生依赖于什么?
运维·windows·电脑·系统
IDC02_FEIYA2 小时前
Windows 服务器任务管理器用户客户端名怎么修改?Windows 10修改电脑设备名称
运维·服务器·windows
Trouvaille ~2 小时前
【Linux】虚拟内存揭秘:地址空间的魔法
linux·运维·服务器·系统·入门·虚拟内存·进程地址空间