Search code examples
nginxnginx-locationjwilder-nginx-proxy

Split request_uri in nginx


I'm new to Nginx, I'm trying to do proxy_pass for a specific format of URL.

For example "http://example.com/sync/test" is the URL accessed by the user, internally the URL has to do proxy_passs to apache server like, "http://localhost:8000/test" need to exclude sync, but now it's` redirecting has "http://localhost:8000/sync/test".

Is there any option to split and get parameters after sync,

Suggestions or solution is appreciated


Solution

  • Rewrite the url by removing /sync/ from the url

    location / {
                 rewrite ^/sync/(.*) /$1 break;
                 proxy_pass http://localhost:8000;
               }