4

is it possible to use Nginx proxy_pass to rewrite URL as below:

location /foo {
    proxy_pass http://external-server-IP:8080/some/path/;
}

1 Answer 1

3

Yup.

location /foo {
    rewrite ^/foo(/.*)$ /some/path$1 break;
    proxy_pass http://external-server-IP:8080;
}
3
  • hi , i am getting error : nginx:[emerg] unknown directive " rewrite" in /opt/nginx/nginx.conf:56
    – Raj kumar
    Oct 27, 2016 at 6:18
  • even adding the proxy_pass in second line didn't help .
    – Raj kumar
    Oct 27, 2016 at 6:37
  • 2
    Your nginx is somehow missing the ngx_http_rewrite_module.
    – drookie
    Oct 27, 2016 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .