nginx 代理背后的 wordpress(来自两个来源的访问) [英] wordpress behind nginx proxy (acces from two sources)

查看:40
本文介绍了nginx 代理背后的 wordpress(来自两个来源的访问)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了一次艰难的搜索,找到了如何让 Word-press 在代理后面显示其页面,我想出了一种方法来正确加载页面链接和样式文件,但是如果出现以下情况,管理页面会抛出 404我尝试使用其中的任何东西.重建 docker-compose 后,管理页面工作目前需要设置 WP_HOME 和 url,有问题,我只能决定页面是在我的网络中工作(通过使用 IP)还是可以从外部访问(通过设置 url)

I had a hard search finding out how to get Word-press to show its page behind a proxy, i figured out a way to get the page-links and style-files loaded correctly, but the admin-pages throw 404 if i try to use anything within them. after rebuilding the docker-compose, admin-page works The current need to set WP_HOME and url, have the problem tat i can only decide if the page works in my network (by using the IP) or is reachable from the outside (by setting the url)

我对 wp-config.php 的更改是添加:

My change to the wp-config.php was to add:

define('WP_HOME','http://192.168.1.108/wordpress');
define('WP_SITEURL','http://192.168.1.108/wordpress');

ngings 位置是:

the ngings location is:

location /wordpress/{
  proxy_buffering off;
  proxy_pass http://wordpress/;
  proxy_redirect default;
}

192.168.1.108 是使用 docker-container 名称http://wordpress/"的到达 nginx 的 IP到达 wordpress.在这里删除了一些错误的条目

192.168.1.108 is the ip to reach nginx which uses the docker-container name "http://wordpress/" to reach wordpress.deleted some false entrys here

PS:这基本上是对 docker 的跟进运行 nginx 作为另一个网络服务器的代理(在 pi 上).

PS: This is basically a followup to docker running nginx as proxy to another webserver (on pi).

-- 编辑--:一些测试(和系统重启)已经改变了上面的一些陈述,他们被改变以适应这一点,以粗体编辑.

-- EDIT --: Some tests (and system restart) have changed some of tha above statements, they were changed to acomodate this, edits in bold.

-- 编辑 2--:我知道一种解决方案是将外部 URL 添加到 hosts.txt(我在网站本身运行的设备上使用它),但对移动设备(需要同时使用内部 IP 和我们端 IP)没有帮助.

-- EDIT 2--: I know one solution is to add the outside-URL to the hosts.txt (i use it on the device the site itself is running on) but tis wont help with mobile devices (which need to use both inside and ourtside IP).

-- 编辑 3--:好的,现在每当我尝试输入 php 生成的页面时,我都设法将我的前置词加倍:我得到 http:///wordpress//wordpress/wp-admin/同样适用于评论.但是登录好像正常(虽然也是php)?

-- EDIT 3--: Ok, now i managed to double my prepends whenever i try to enter a php generated page: I get http:///wordpress//wordpress/wp-admin/ same goes for comments. But login seems to work normal (altough it also is a php)?

推荐答案

我想我找到了缺失的那一行(我把 IP 改成了一个名字,我输入到 host.txt 中)

I think i have found the missing line (and i changed the IP to a name, which i entered to the host.txt)

ngings 位置是:

the ngings location is:

location /wordpress/{
proxy_buffering off;
proxy_pass http://wordpress/;
proxy_redirect off;
}

(我不确定关闭是否比默认更好)

(i am not sure if off is better than default)

我对 wp-config.php 的更改是添加:

My change to the wp-config.php was to add:

$_SERVER['HTTP_HOST']=$_SERVER['HTTP_X_FORWARDED_HOST'];
define('WP_HOME','http://<NAME>/wordpress');
define('WP_SITEURL','http://<NAME>/wordpress');

同样重要的是:如果在 docker-compose 中进行测试,请确保正确清洁它.

Also important: if testing inside a docker-compose make sure to clen it properly.

这篇关于nginx 代理背后的 wordpress(来自两个来源的访问)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆