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
修改 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']);