user root; #设置nginx服务的系统使用用户
worker_processes 1; #工作进程数
error_log /var/log/nginx/error.log warn; #nginx的错误日志
pid /var/run/nginx.pid; #nginx启动时候的pid
events {
worker_connections 1024; #每个进程允许的最大连接数
}
http { #http请求配置,一个http可以包含多个server
#定义 Content-Type
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$http_user_agent' '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#客户端与服务端的超时时间,单位秒
keepalive_timeout 65;
#gzip on;
server { #http服务,一个server可以配置多个location
listen 80; #服务监听端口
server_name localhost; #主机名、域名
rewrite ^/(index.html)?$ /wcRobot/Default.html redirect;
location / {
root /usr/share/nginx/html; #页面存放目录
index index.html index.htm; #默认页面
try_files $uri index.html;
add_header Access-Control-Allow-Methods * always;
add_header Access-Control-Allow-Origin $http_origin always;
}
#nginx代理转发配置
location /identity/{
proxy_pass http://192.168.2.102.81/;
}
location /config/{
proxy_pass http://192.168.2.102.82/;
}
location /algorithm/{
proxy_pass http://192.168.2.102.83/;
}
#error_page 404 /404.html;
# 将500 502 503 504的错误页面重定向到 /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html { #匹配error_page指定的页面路径
root /usr/share/nginx/html; #页面存放的目录
}
}
include /etc/nginx/conf.d/*.conf;
}
nginx 文件配置
最新推荐文章于 2024-05-23 11:22:18 发布