【发布时间】:2016-08-30 14:42:25
【问题描述】:
我对 nginx 和 wordpress 都是新手。 我已将我的项目配置为通过 nginx 服务器提供服务。现在我们需要将 wordpress 博客支持添加到我们的项目中。 我的 nginx 在 80 端口上运行。而 Apache 在安装了我的 wordpress 的 8181 上运行。
现在任何去博客的 url 都会通过我的 nginx 服务器重定向到 8181 上的 apache。
下面是我的博客网址的 nginx 重定向。
location /blog {
proxy_pass http://127.0.0.1:8181/blog/;
proxy_redirect https://192.168.1.54 http://127.0.0.1:8181/blog;
proxy_read_timeout 3500;
proxy_connect_timeout 3250;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header SSL_PROTOCOL $ssl_protocol;
proxy_set_header SSL_CLIENT_CERT $ssl_client_cert;
proxy_set_header SSL_CLIENT_VERIFY $ssl_client_verify;
proxy_set_header SSL_SERVER_S_DN $ssl_client_s_dn;
}
为了了解 Google 页面速度,我在下面进行了配置。
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
}
现在,我在这里面临的问题是,当一些 css 或 js 请求来自 wordpress 例如。 http://192.168.1.54/blog/wp-content/themes/twentysixteen/style.css?ver=4.6 被困在为 css 编写的位置配置中,即。 location ~* .(?:ico|css|js|gif|jpe?g|png|woff)$ 因此 wordpress 无法获取 css 或 js。
所以,我需要你的帮助,将 nginx 上 blog 请求的任何 URL 重定向到 8181 端口上的 Apache 服务器。包括js和css。 像https://192.168.1.54/js/somejs.js 这样的其他与资源相关的网址也应该可以工作。
我在 wordpress 文件中做了一些配置更改 wp-config.php
define('WP_HOME', 'https://192.168.1.54/blog');
define('WP_SITEURL', 'https://192.168.1.54/blog');
【问题讨论】:
标签: php wordpress apache nginx location