我很难理解这个Nginx配置中的POST请求是怎么回事。根据我在那里添加的调试消息,在这里发布请求时,添加的头是X-debug-messages 0和4.看起来像位块正被完全忽略。有什么想法吗?
daemon off;
user www-data;
worker_processes 2;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server {
resolver 8.8.8.8;
listen 80 default_server;
location / {
proxy_pass $scheme://<dest>$request_uri;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name <hostname>;
add_header X-debug-message0 "In the hostname server block" always;
location / {
add_header X-debug-message1 "Checking for POST method" always;
if ($request_method = POST) {
add_header X-debug-message2 "Ready for proxy_pass" always;
proxy_pass https://www.<hostname>$request_uri;
break;
}
add_header X-debug-message3 "Skipped proxy_pass" always;
break;
}
add_header X-debug-message4 "Going to redirect" always;
return 301 https://www.<hostname>$request_uri;
}
server {
listen 443;
server_name <hostname>;
ssl on;
ssl_certificate /app/certs/cert.pem;
ssl_certificate_key /app/certs/cert.key;
return 301 https://www.<hostname>$request_uri;
}
}