使用 Nginx 和 Apache 的 Node 旁边的 Wordpress
Wordpress along side Node using Nginx and Apache
我正在尝试在 /blog 上托管一个 wordpress。我使用 Nginx 作为代理和 Apache 运行 Wordpress。我认为我非常接近一个可行的解决方案。
我现在面临的唯一问题是 /blog/wp-admin 加载 wordpress 仪表板,但随后某些内容正在重写或重定向到 /wp-admin。前端页面正常,例如:/blog/2015/05/28/hello-world/.
我如何找出谁在将仪表板 url 从 www.example.com/blog/wp-admin 重写为 www.example.com/wp-admin/ ?
这是我的 Nginx 配置:
upstream app_node {
server 127.0.0.1:3000;
}
upstream app_wordpress {
server 127.0.0.1:8080;
}
server {
listen 0.0.0.0:80;
server_name example.com;
access_log /var/log/nginx/node.log;
error_log /var/log/nginx/node.error.log debug;
#port_in_redirect off;
rewrite_log on;
client_max_body_size 50M;
# pass the request to the node.js server with the correct headers
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_node/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~ ^\/blog(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}
Apache 配置:
<VirtualHost *:8080>
ServerName example.com:8080
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel alert rewrite:trace6
</VirtualHost>
Wordpress htaccess(wordpress 文件位于 /var/www/html):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我找到了一个方法,但做了一些改动。
步骤 1.
按照描述将 wordpress 移动到 /var/www/html/blog here
第 2 步
- Nginx 配置不变
- Apache 配置未更改
.htaccess 由 wordpress 生成:
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
步骤 3.
Wordpress > 设置 > 常规
- WordPress 地址(URL):http://example.com:8080/blog
- 站点地址(URL):http://example.com/blog
我正在尝试在 /blog 上托管一个 wordpress。我使用 Nginx 作为代理和 Apache 运行 Wordpress。我认为我非常接近一个可行的解决方案。
我现在面临的唯一问题是 /blog/wp-admin 加载 wordpress 仪表板,但随后某些内容正在重写或重定向到 /wp-admin。前端页面正常,例如:/blog/2015/05/28/hello-world/.
我如何找出谁在将仪表板 url 从 www.example.com/blog/wp-admin 重写为 www.example.com/wp-admin/ ?
这是我的 Nginx 配置:
upstream app_node {
server 127.0.0.1:3000;
}
upstream app_wordpress {
server 127.0.0.1:8080;
}
server {
listen 0.0.0.0:80;
server_name example.com;
access_log /var/log/nginx/node.log;
error_log /var/log/nginx/node.error.log debug;
#port_in_redirect off;
rewrite_log on;
client_max_body_size 50M;
# pass the request to the node.js server with the correct headers
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_node/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~ ^\/blog(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}
Apache 配置:
<VirtualHost *:8080>
ServerName example.com:8080
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel alert rewrite:trace6
</VirtualHost>
Wordpress htaccess(wordpress 文件位于 /var/www/html):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我找到了一个方法,但做了一些改动。
步骤 1.
按照描述将 wordpress 移动到 /var/www/html/blog here
第 2 步
- Nginx 配置不变
- Apache 配置未更改
.htaccess 由 wordpress 生成:
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
步骤 3.
Wordpress > 设置 > 常规
- WordPress 地址(URL):http://example.com:8080/blog
- 站点地址(URL):http://example.com/blog