Question
how to proxy rewrite but preserve url
I am totally new to this proxy stuff so bear with me and may not be using the right terminology
We have setup a proxy to our ec2 instance where we have a few dokku/docker containers that are hosting a few apps. the url for those apps are:
http://foo.dokku.abc.domain.com
http://bar.dokku.abc.domain.com
We would like to be able to have users only type:
http://foo.abc.domain.com
http://bar.abc.domain.com
we’ve setup a rewrite for the above urls which works fine.
http://foo.abc.domain.com -> http://foo.dokku.abc.domain.com
http://bar.abc.domain.com -> http://bar.dokku.abc.domain.com
however we would like it to not actually rewrite the url, we’d like it to preserve the url in the browser.
What can we do to fix this?
thanks
below is the code in /etc/nginx/sites-available/default
server {
listen 80 ;
server_name .dokku.abc.domain.com;
location / {
proxy_pass http://ip-aaa-bbb-ccc-ddd.us-west-1.compute.internal:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80 ;
server_name foo.abc.domain.com;
rewrite ^(.*) http://foo.dokku.abc.domain.com;
}
server {
listen 80 ;
server_name bar.abc.domain.com;
rewrite ^(.*) http://bar.dokku.abc.domain.com;
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×