1

I am facing the similar issue as described here: How to stop nginx 301 auto redirect when trailing slash is not in URI?

Yet in my case the confifuration is a little bit different. I am using the Host header value to set a "virtual domain" that I am passing to the upstream apache. So the redirect should NEVER occur by nginx - the desired behaviour would be just passing the request as it is to the upstream apache. I cannot afford to put the magnitudes of location directive, because it is just too unelegant and cumbersome. Any ideas how to disable nginx redirects while using proxy_pass?

Edit: I wonder if it can be done via proxy_intercept_errors and error_page directives + some handler. It is unclear what should be done in the handler though.. will nginx pass the request upstream if I just declare an empty handler? Or I should specify proxy_pass (as well as all other related options, provided I am using SSL for upstream connection) again?

Edit: eventually decided against the usage of "virtual domain" and just specified a real one (both in the nginx prozy and in upstream apache); at the same time on the upstream apache server I restricted access only to specific IP addresses. It would be nice to understand how to deal with nginx, but there is simply no time for that. :(

3
  • I'm afraid without seeing your configuration file (as the person asking the question in the link you gave provided) it is often hard to even start guessing as to the issue. Could you add a snippet of your configuration to your question?
    – Anon
    Aug 13, 2019 at 5:03
  • Please show the complete server block. Aug 13, 2019 at 7:18
  • @Anon Uh oh. I thought it is not such hard of an issue and it could be resolved theoretically without much hussle with configs and all. Okay I will drop the config a little bit later on. Aug 13, 2019 at 12:44

1 Answer 1

0

Use proxy_redirect

location /user/ { proxy_pass http://user.example.com; proxy_redirect http://$proxy_host:9001 http://$host:80; }

location = /user { proxy_pass http://login.example.com; proxy_redirect http://$proxy_host:9001 http://$host:80; }

Thanks,

1
  • I tried to use proxy_redirect. It doesn't work with 301 redirects. I will update the question with a config a little bit later on. Aug 13, 2019 at 12:45

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.