My problem seems similar with $_POST is empty. Nginx OSx , $_POST is empty in nginx and $_GET filled but $_REQUEST is empty, however I cannot find a solution to work for me there.
Long story short, I cannot get my POST request through to a file named server.php
on my server.
Let's assume that my server.php
contains only something like:
<?php var_dump($_REQUEST);
and my sites-available/domain.tld
file contains the following:
server {
root /var/www/domain.tld/current/dist;
index index.html index.htm;
server_name domain.tld;
location / {
try_files $uri $uri/ index.php?$query_string =404;
}
location ~ \.php$ {
#limit_except POST {
# allow 127.0.0.1;
# deny all;
#}
#if ( $request_method !~ ^POST$ ) {
# return 405;
#}
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
#fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param REQUEST_METHOD $echo_request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REQUEST_BODY $request_body;
fastcgi_param QUERY_STRING $query_string;
}
location ~ /\.ht {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name www.domain.tld;
return 301 $scheme://domain.tld$request_uri;
}
server {
if ($host = domain.tld) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name domain.tld;
return 404; # managed by Certbot
}
Whatever 'POST' request I am making on the server.php
will just not send any parameters through.
Output of server.php
would be array(0) {}
Some other info:
Request is made on Request URL:
https://domain.tld/server.php
Request Method:
POST
Status Code:
200 OK
A GET request sent like https://domain.tld/server.php?foo=bar
will show me the correct foo
variable sent over with a value of bar
If needed I can provide details on the request itself. (using axios
in a vue
app).
Please advise...