165 lines
4.8 KiB
Nginx Configuration File
165 lines
4.8 KiB
Nginx Configuration File
worker_processes auto;
|
||
worker_rlimit_nofile 65535;
|
||
error_log /var/log/nginx/error.log;
|
||
pid /var/run/nginx.pid;
|
||
|
||
events {
|
||
worker_connections 8192;
|
||
use epoll;
|
||
multi_accept on;
|
||
}
|
||
|
||
http {
|
||
# 日志格式
|
||
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 /var/log/nginx/access.log main;
|
||
|
||
# 基础配置
|
||
client_max_body_size 100m;
|
||
sendfile on;
|
||
tcp_nopush on;
|
||
tcp_nodelay on;
|
||
keepalive_timeout 65;
|
||
types_hash_max_size 2048;
|
||
|
||
# Gzip 压缩(http 级别)
|
||
gzip on;
|
||
gzip_disable "msie6";
|
||
gzip_vary on;
|
||
gzip_proxied any;
|
||
gzip_comp_level 6;
|
||
gzip_buffers 16 8k;
|
||
gzip_http_version 1.1;
|
||
gzip_min_length 256;
|
||
gzip_types text/plain text/css application/json application/x-javascript
|
||
text/xml application/xml application/xml+rss
|
||
application/javascript text/javascript
|
||
application/vnd.ms-fontobject application/x-font-ttf
|
||
font/opentype image/svg+xml image/x-icon;
|
||
|
||
# 代理超时配置
|
||
proxy_connect_timeout 300s;
|
||
proxy_send_timeout 300s;
|
||
proxy_read_timeout 300s;
|
||
send_timeout 300s;
|
||
|
||
include /etc/nginx/mime.types;
|
||
default_type application/octet-stream;
|
||
|
||
# =============================================
|
||
# 主 Server 块
|
||
# =============================================
|
||
server {
|
||
listen 80 default_server;
|
||
absolute_redirect off;
|
||
server_name _;
|
||
|
||
# Gzip 压缩(server 级别,微调)
|
||
gzip_min_length 1024;
|
||
gzip_types text/plain text/css application/json application/javascript
|
||
application/x-javascript text/xml application/xml
|
||
application/xml+rss text/javascript image/svg+xml;
|
||
|
||
# 健康检查
|
||
location /healthcheck {
|
||
access_log off;
|
||
return 200 'OK';
|
||
add_header Content-Type text/plain;
|
||
}
|
||
|
||
# Ping 接口
|
||
location /ping {
|
||
return 200 "ok";
|
||
}
|
||
|
||
# API 代理(网关)
|
||
location ~ ^/(mhzc|gxzx|sso|yygl) {
|
||
include proxy-common.conf;
|
||
proxy_pass http://txw-gateway:9300;
|
||
}
|
||
|
||
# 百度验证
|
||
location = /baidu_verify_codeva-5rH3psCeMQ.html {
|
||
alias /etc/nginx/verify/baidu_verify_codeva-5rH3psCeMQ.html;
|
||
}
|
||
|
||
location = /baidu_verify_codeva-eE1giHswVL.html {
|
||
return 200 "2c7cc0bcf0ecd060ab8f7fe919acc078";
|
||
add_header Content-Type text/html;
|
||
}
|
||
|
||
# --------------------------------------------------------
|
||
# 运营支撑前端(mhzc)
|
||
# --------------------------------------------------------
|
||
location /view/mhzc {
|
||
return 301 /view/mhzc/;
|
||
}
|
||
|
||
location /view/mhzc/ {
|
||
alias /usr/share/nginx/html/txw-mhzc-web/;
|
||
|
||
# 静态资源(90天缓存)
|
||
location ~* \.(gif|jpg|jpeg|png|css|js|ico|eot|svg|ttf|woff|woff2)$ {
|
||
expires 90d;
|
||
add_header Cache-Control "public";
|
||
try_files $uri =404;
|
||
}
|
||
|
||
# 非静态资源(1小时缓存)
|
||
expires 1h;
|
||
add_header Cache-Control "public";
|
||
|
||
try_files $uri $uri/ /view/mhzc/index.html;
|
||
}
|
||
|
||
# --------------------------------------------------------
|
||
# 运营管理前端(yygl)
|
||
# --------------------------------------------------------
|
||
location /view/yygl {
|
||
return 301 /view/yygl/;
|
||
}
|
||
|
||
location /view/yygl/ {
|
||
alias /usr/share/nginx/html/txw-yygl-web/;
|
||
|
||
# 静态资源(90天缓存)
|
||
location ~* \.(gif|jpg|jpeg|png|css|js|ico|eot|svg|ttf|woff|woff2)$ {
|
||
expires 90d;
|
||
add_header Cache-Control "public";
|
||
try_files $uri =404;
|
||
}
|
||
|
||
# 非静态资源(1小时缓存)
|
||
expires 1h;
|
||
add_header Cache-Control "public";
|
||
|
||
try_files $uri $uri/ /view/yygl/index.html;
|
||
}
|
||
|
||
# --------------------------------------------------------
|
||
# 默认首页重定向
|
||
# --------------------------------------------------------
|
||
location / {
|
||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||
add_header Pragma "no-cache";
|
||
add_header Expires 0;
|
||
return 301 /view/mhzc/;
|
||
}
|
||
|
||
# 错误页面
|
||
error_page 404 /404.html;
|
||
location = /404.html {
|
||
}
|
||
|
||
error_page 500 502 503 504 /50x.html;
|
||
location = /50x.html {
|
||
}
|
||
}
|
||
|
||
# 引入其他 location 配置
|
||
include ./location.d/*.conf;
|
||
}
|