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;

}

}

}

相关推荐
山上三树几秒前
操作系统如何实现各种功能
linux·运维·服务器
妹妹够啦7 分钟前
PyCharm创建venv环境
linux·运维·服务器
Tim风声(网络工程师)15 分钟前
iMaster NCE-Campus和iMaster NCE-Fabric的区别
运维·fabric
我爱小疯喵喵17 分钟前
5 Linux apt下载软件包
linux·运维·服务器
坚持就完事了19 分钟前
Linux中的tr命令
linux·运维·服务器
xingyuzhisuan22 分钟前
影视动画渲染租用RTX4090 GPU服务器的优势及选型指南
运维·服务器·ai编程·gpu算力
TG_yunshuguoji27 分钟前
阿里云代理商:DeepSeek V4 API接入全攻略 + 云服务器部署指南
运维·阿里云·云计算·ai智能体·deepseek-v4
很懒的程序员雄33 分钟前
eNSP企业级复杂拓扑
运维·服务器·网络
zhuxiaohai6834 分钟前
ubuntu24.04安装docker(国内加速方法)
运维·docker·容器
xhbh66636 分钟前
Java端口转发完全教程:从Socket基础到Netty高并发实战
运维·服务器·网络·流量端口转发·netsh 端口转发