跳至内容
Taijicoder Wiki
用户工具
登录
站点工具
搜索
工具
显示页面
过去修订
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
•
Build Emacs on macOS
let_wordpress_proxied_by_nginx
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
## 让Nginx 来代理 Wordpress 提供服务 ### 前提 1. nginx 对外提供服务的wordpress 路径为: http://www.example.com/blog 2. wordpress 服务的实际地址为 http://127.0.0.1:8080 ### 步骤一 设置 Nginx ``` location ^~ /blog/ { proxy_pass http://127.0.0.1:8080/; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } ``` ``` # 重新加载 nginx 配置 $ systemctl reload nginx ``` ### 步骤二 设置 Wordpress 修改 wp-config.php 文件,添加如下内容 ``` /** set the site URL */ define('WP_HOME','http://www.example.com/blog'); define('WP_SITEURL','http://www.example.com/blog'); /** Fix to get the dashboard working with the reverse proxy.*/ $_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/", $_SERVER['REQUEST_URI']); ``` #### 查看wordpres 数据库的 wp_options 表 1. 修改 option\_name 为 siteurl 的 option\_value 为 /blog 2. 修改 option\_name 为 home 的 option\_value 为 /blog ### 参考链接 [NGINX Proxy to wordpress website](https://stackoverflow.com/questions/38205743/nginx-proxy-to-wordpress-website) [Fix wordpress redirect when it behind a reverse proxy](https://wordpress.stackexchange.com/questions/52801/possible-to-fix-admin-url-behind-proxy-issue-without-hacking-core?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa)
let_wordpress_proxied_by_nginx.txt
· 最后更改:
2024/02/04 04:49
由
127.0.0.1
页面工具
显示页面
过去修订
反向链接
回到顶部