3

I need nginx to reverse- proxy GET and POST requests of the form:

/myapp/path/to/resource 

to:

http://127.0.0.1:9090/path/to/resource

I'm trying the following:

location /myapp/(.*) {
  rewrite $1;
  proxy_pass http://127.0.0.1:9090;
}

but nginx is returning a HTTP 405 error [not allowed].

Any ideas on how to fix this ? Thanks.

1
  • Was you able to fix this, I have similar problem, I have the same requirements e.g. /myApp1/A to 127.0.0.1:8080/A and /myApp2/A to 127.0.0.1:8081/A Commented Jul 27, 2023 at 6:03

1 Answer 1

5

You don't actually need to do a rewrite. You can achieve the same end with the following:

location /myapp/ {
  proxy_pass http://127.0.0.1:9090/;
}
Sign up to request clarification or add additional context in comments.

1 Comment

You probably meant to leave the 'myapp' off of the proxy_pass.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.