我有一个 nginx 作为后端前面的代理,我想将对特定位置发出的请求分离到一个单独的文件中。
请求仍然应该发送到同一个后端服务器,但我不想在主访问日志中看到它们。
另外我不想指定所有的 proxy_ 东西两次。
server {
...
access_log /var/log/nginx/jira.access.log full;
error_log /var/log/nginx/jira.error.log;
client_max_body_size 150m;
location /special/ {
}
location / {
# many lines of config params for proxy_...
proxy_pass http://dowa-02.example.com:8080;
...
}
}
Run Code Online (Sandbox Code Playgroud)
UPD
嗯...access_log指令有一个“功能”。
请求记录在处理结束的位置的上下文中。如果在请求处理期间发生内部重定向,这可能与原始位置不同。
在try_files内部重定向的情况下。尝试改变try_files到include和删除命名的位置。
UPD 结束
例如,为了不重复多次“proxy_ stuff”,您可以使用include指令。但是try_files和命名位置要好得多:)
server {
...
access_log /var/log/nginx/jira.access.log full;
error_log /var/log/nginx/jira.error.log;
client_max_body_size 150m;
location /special/ {
try_files $uri @backend;
access_log /var/log/nginx/special.access.log full;
}
location / {
try_files $uri @backend;
}
location @backend {
# many lines of config params for proxy_...
proxy_pass http://dowa-02.example.com:8080;
...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24224 次 |
| 最近记录: |