Nginx rewrite urls to match proxy address
-
I am running a wordpress docker container , the site is accessible through host machines port 8000 , if go to localhost:8000 boom i get to see my wordpress site.
It’s boring to always type localhost:8000 to see my website, so i decided to commission nginx as a reverse proxy for my site. I’ve set up a virtual host in nginx that has the name proxy.site , i can now access by wordpress site by visiting https://proxy.site.
Up until this point, we are doing great, when https://proxy.site opens up, i can see a list of my blog posts, lets say i want to read my latest blog post about COVID-19 , when i click on the link, ohohohoho it opens up as https://localhost:8000/posts/covid19
I want it to open with the proxy url as in https://proxy.site/posts/covid19 , i need to whole site to be accessible through the https://proxy.site site name,
I need nginx to rewrite all my links in localhost:8000/* to proxy.site/* , no body loves typing ports when accessing a blog,
Here is how my nginx conf file looks like
server { listen 80; listen [::]:80; root /var/www/proxy.site/html; index index.html index.htm index.nginx-debian.html; server_name proxy.site www.proxy.site; location / { proxy_pass https://localhost:8000; #proxy_set_header HOST $host; #proxy_redirect https://localhost:8000/ https://proxy.site/ ; #try_files $uri $uri/ =404; } }
How do i achieve rewrite all urls in the proxied site with my custom host name ?
- The topic ‘Nginx rewrite urls to match proxy address’ is closed to new replies.