Score:0

Nginx proxy remove spesific path and emty Post request body

cn flag
zgr

I'm using nginx for web service proxy. I have rest service as below and i want to proxy my domain with suburi

https://www.example.com/myRestservice

Service has some method like this;

http://1.1.1.1:123/api/work/method1
http://1.1.1.1:123/api/work/method2

As result i want to access to methods of service like

https://www.example.com/Restservice/api/work/method1..

When i try to use rewrite in nginx as below, i can access service. But in this time Post method's request body is emty. I can see service logs.

In my nginx.config

upstream RestService {
   server 1.1.1.1:123;
   server 1.1.1.2:123;
}
server {
       listen                443 ssl;
       server name           https://www.example.com;

location ~ ^/Restservice/ {
          
   add_header Access-Control-Allow-Origin *;
   rewrite ^/Restservice/(.*) /$1 break;
   proxy_pass http://Restservice/;
   proxy_http_version  1.1;
}
}

I try to location part like this, result is same.

 location   /Restservice { 
   
   proxy_pass http://Restservice/;
}

In nginx access log;

status : 500 request: POST /Restservice/api/work/method1 HTTP/1.1
Ivan Shatsky avatar
gr flag
There is a little help from the access log entry. Please add the corresponding error log entry to your question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.