我有两个域(site1.com,site2.com)运行在单个服务器上,site1运行在服务器本身的端口80上,而site2运行在基于wordpress docker映像的端口8082上。使用以下命令启动docker:
docker run --privileged -itd --name wordpress2 -e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_NAME=wp2 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=pass -p 8082:80 --link mysql:mysql wordpress
由于site1.com已经占用了80个端口,因此我不能要求用户指定8082端口号来访问site2.com,因此我设置了如下的nginx proxy_pass规则:
server
{
listen 80;
server_name www.site2.com;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8082;
}
}
但是当我在Chrome中以http://www.site2.com输入网址时,它仍然跳至8082端口,这是卷曲结果。
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Sat, 24 Aug 2019 09:29:40 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
X-Powered-By: PHP/7.3.7
Set-Cookie: PHPSESSID=ea2c8aa5c9dfbf79046440cc8f66d35e; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-Redirect-By: WordPress
Location: http://www.site2.com:8082/
有人可以帮忙解释一下原因以及如何使其成为普通网站吗?
=========================
解决了,只是忘了更改wordpress的SITEURL和HOME设置,再次感谢RichardSmith的帮助!