nginx配置文件模板
时间: 2023-08-26 09:10:55 浏览: 161
回答: 以下是一个nginx配置文件的模板示例:
```
access_log /usr/local/nginx/logs/access.log main;
server_tokens off;
sendfile on;
#tcp_nopush on;
upstream backend {
server 127.0.0.1:8010 weight=1;
server 127.0.0.1:8080 weight=2;
server 127.0.0.1:8030 weight=1 backup;
}
location / {
proxy_pass http://backend;
}
location /idi2.0 {
proxy_pass http://127.0.0.1:8004;
add_header Location $host;
root /apps/idi/web;
if (-d $request_filename){
rewrite ^/(.*)(\[^/\])$ $scheme://$host/$1$2/ permanent;
}
index index.html index.htm;
}
location /idiApp {
proxy_pass http://127.0.0.1:8003;
add_header Location $host;
root /apps/idi/web;
if (-d $request_filename){
rewrite ^/(.*)(\[^/\])$ $scheme://$host/$1$2/ permanent;
}
index index.html index.htm;
}
location /iidi/ {
proxy_pass http://127.0.0.1:8005/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_redirect off;
add_header Access-Control-Allow-Origin *;
add_header Content-Security-Policy "default-src 'self'";
add_header Referrer-Policy: origin;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
```
这个模板包含了一些常见的nginx配置项,如日志记录、负载均衡、代理等。你可以根据自己的需求进行修改和扩展。
#### 引用[.reference_title]
- *1* *3* [nginx配置模板](https://blog.csdn.net/weizhen1209/article/details/131081228)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [nginx常用配置模板](https://blog.csdn.net/sly1311220942/article/details/123423983)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文