nginx POST request becomes GET.
Blazor server(httpclient request https://www.youdomain.com)->nginx->http://localhost:8100(.net core Web Api)
I am developing an Android and a server application in .net core web api. The server application runs on Jetty. The Android application is emulated on the same computer.
The Android application sends a POST request to the server, but the handler of the server interpret it as a GET.
When I use Send HTTP Tool to simulate POST request, it works perfectly (I mean the type of the method is POST).
To add HTTP and WebDAV methods like PUT, DELETE, MKCOL, COPY and MOVE you need to nginx with HttpDavModule
The ngx_http_dav_module module is intended for file management automation via the WebDAV protocol. The module processes HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY, and MOVE.
This module is not built by default, it should be enabled with the --with-http_dav_module configuration parameter.
Step 1:Check nginx -V first, maybe you already have the HttpDavModule
nginx version: nginx/1.14.0 (Ubuntu)
built with OpenSSL 1.1.1 11 Sep 2018
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-DUghaW/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module
Step 2: Nginx https rewrite turns POST to GET
My problem with this was that I was requesting an HTTP request, which was getting 301 redirected to HTTPS. Using HTTPS for the requests solves this issue.
before
http://www.youdomain.com
Now
https://www.youdomain.com
Then change your nginx-config like that:
ocation / {
root /var/www;
dav_methods PUT;
}
nginx docs entry for the HttpDavModule.
http://nginx.org/en/docs/http/ngx_http_dav_module.html
Nginx https rewrite turns POST to GET
https://serverfault.com/questions/434205/nginx-https-rewrite-turns-post-to-get