Reputation: 313
I'm using Nginx as a reverse proxy with SSL to route requests to a backend server. However, when I send POST
requests, they’re received as GET
requests on the backend.
server {
listen 80;
server_name api.mydomain www.api.mydomain;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name api.mydomain www.api.mydomain;
ssl_certificate /home/cert_chain.crt;
ssl_certificate_key /home/p.key;
location / {
proxy_pass http://localhost:3110;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
When I send a POST
request to https://api.mydomain/endpoint
, it reaches my backend server on localhost:3210
as a GET
request instead.
access log
[27/Oct/2024:10:29:16 +0100] "POST /api/v1/user/register HTTP/1.1" 301 178 "-" "PostmanRuntime/7.42.0"
[27/Oct/2024:10:29:18 +0100] "GET /api/v1/user/register HTTP/1.1" 404 35 "http://api.mydomain/api/v1/user/register" "PostmanRuntime/7.42.0"
Thanks very much!
Upvotes: 1
Views: 53