Reputation: 541
I configure a reverse proxy in my nginx.conf, and it works very well.
location /foo/ {
proxy_pass http://localhost:5000/;
proxy_intercept_errors on;
proxy_redirect off;
}
and I also handle the error request:
location @404 {
#redirect to http://localhost:5000/foo/index.html
return 302 /foo/index.html;
}
error_page 404 = @404;
As you can see, I use 302 to redirect to the index.html. also works perfectly so far.
But what I want is not redirect. I want to forward the index page to browser.
(the reason I need forward is I want to handle the refresh problem when I enable the html5mode and remove the #
in angularjs app.)
So is there a way to do this?
Upvotes: 2
Views: 112
Reputation: 49792
Your named location is forcing a redirect. The error_page
handling does not require a redirect. You can specify a local URI in the error_page
statement, that is handled by your proxy location:
For example:
location /foo/ {
proxy_pass http://localhost:5000/;
proxy_intercept_errors on;
proxy_redirect off;
}
error_page 404 = /foo/index.html;
See this document for more.
Upvotes: 1