Nginx rewrite urls to match proxy address
March 25, 2020 01:19AM
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 , i can now access by wordpress site by visiting

Up until this point, we are doing great, when 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 http://localhost:8000/posts/covid19

I want it to open with the proxy url as in , i need to whole site to be accessible through the site name,

I need nginx to rewrite all my links in localhost:8000/* to* , 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/;
index index.html index.htm index.nginx-debian.html;


location / {
proxy_pass http://localhost:8000;
#proxy_set_header HOST $host;
#proxy_redirect http://localhost:8000/ ;
#try_files $uri $uri/ =404;

How do i achieve rewrite all urls in the proxied site with my custom host name ?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 49
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready