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