Issue
I have a Nginx running as a reverse proxy, with on the same machine a Wordpress website. Both are docker containers. I have a domain with A-record to my public IP, and I have port-forwarding enabled so that port 80 is forwarded to the host machine. Only Nginx is mapped to port 80 of that machine, the port of Wordpress (also 80) is not mapped to a host port and is not reachable outside of going through Nginx.
So far so good. If I connect to the website using the local host IP, it works (as in, nginx correctly proxies me to the website). However, if I use the domain, then it does a 301 to the local (!) address of the host. So, I type exampledomain.com in my browser and it redirects me to 192.168.1.x (the local IP of the host machine running the nginx and wordpress containers).
I have been searching a lot on Google but haven't been able to find the right answer on this one unfortunately. I assume I do something wrong in the config of Nginx, which is the following:
events {}
http {
server {
listen 80;
server_name exampledomain.com www.exampledomain.com;
location / {
proxy_pass http://wordpress;
proxy_pass_request_headers on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
}
This is still only on port 80, but I am planning on making sure that any port 80 request is forwarded to port 443. However, I can't seem this first step to work, so let's focus on that first. How do I make sure it doesn't redirects my request to the local IP address but actually retains the exampledomain.com in the browser address bar?
Solution
For those who are running into the same thing: @Richard Smith provided the correct answer in the comment of the question. You need to change the site URL under Settings/General in Wordpress.
Answered By - JarroVGIT Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.