upstream testService {
ip_hash;
server 192.168.1.150:8298;
}
server {
listen 80;
server_name localhost;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
client_max_body_size 100m;
client_body_buffer_size 100m;
location / {
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
root /opt/project/tp/tp_html/;
index index.html;
}
error_page 500 502 503 504 /50x.html;
# 导出文件根目录
location /files/ {
if ($request_filename ~* ^.*?.(txt|doc|rar|gz|zip|docx|exe|xlsx|ppt|pptx|xls)$){
add_header Content-Disposition attachment;
}
if ($request_filename ~* ^.*?.(pdf|jpg|png)$){
add_header Content-Disposition inline;
#add_header Content-Type application/pdf;
}
alias /usr/test/;
}
location ^~ /tp/ {
rewrite ^/tp/(.*)$ /$1 break;
index index.html;
proxy_pass http://testService;
}
location ^~ /test/tools/ {
rewrite ^/test/(.*)$ /other/$1 break;
index index.html;
proxy_pass http://testService;
}
location = /50x.html {
root html;
}
}
Nginx配置文件tp.conf
最新推荐文章于 2024-12-17 16:56:19 发布
该配置文件描述了Nginx服务器的详细配置,包括upstream模块用于负载均衡,location指令处理不同路径的请求,如重定向、静态文件处理和代理转发到内部服务。此外,还设置了错误页面、客户端请求体大小限制以及文件下载的Content-Disposition头信息。

408

被折叠的 条评论
为什么被折叠?



