My nginx server has recently started losing the data sent in post requests. I have read that this is due to redirects, mostly from http to https and vice versa. The solutions I have found involve returning a 308 (permanent redirect) instead to preserve post data. To test this, I created a simple php script that just vardumps $_GET and $_POST. However this has not solved the issue of the post requests dropping completely. below is my nginx server config:
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certifcate /path/to/ssl/certificate.crt;
ssl_certificate_key /path/to/cert/key.key;
ssl_stapling on;
ssl_stapling_verify on;
root /path/to/files;
index index.html index.php;
server_name sub.domain.us;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /path/to/files;
index index.html index.php;
server_name sub.domain.us;
location / {
return 308 https://sub.domain.us$request_uri;
}
}
Any insights into why the request bodies are still dropping would be much appreciated.
source https://stackoverflow.com/questions/75823244/why-is-my-nginx-server-dropping-post-request-bodies
No comments:
Post a Comment