[英]Proxy pass mywebsite with nginx to another server wordpress blog
I do proxy pass mywebsite.com/blog to another server which a wordpress is serves on that.我将 mywebsite.com/blog 代理传递到另一台服务器,该服务器上有一个 wordpress。
when I go to mywebsite.com/blog it's okay everything but when I do something or edit something on wordpress admin it suddenly redirect to mywebsite.com/wp-admin instead of mywebsite.com/blog/wp-admin当我访问 mywebsite.com/blog 时一切正常,但是当我在 wordpress admin 上做某事或编辑某事时,它突然重定向到 mywebsite.com/wp-admin 而不是 mywebsite.com/blog/wp-admin
This is my main website.com nginx config:这是我的主要 website.com nginx 配置:
server {
listen 80;
server_name mywebsite.com;
root /var/www/html/laravel-app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ^~ /blog/ {
rewrite ^/blog(/?.*)$ $1 break;
proxy_set_header Host 1.2.3.4;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://1.2.3.4/;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
this another server which serves wordpress blog:这是另一台为 wordpress 博客提供服务的服务器:
server {
listen 80;
root /var/www/html/wordpress-blog;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Try running this general mySQL query on Wordpress Database (replace olddomain and newdomain with mywebsite.com and mywebsite.com/blog):尝试在 Wordpress 数据库上运行这个通用的 mySQL 查询(用 mywebsite.com 和 mywebsite.com/blog 替换 olddomain 和 newdomain):
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://olddomain.com', 'http://newdomain.com');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.