dooid3005 2016-01-24 07:54
浏览 126

在nginx转发后保持域名相同?

I have a setup that is presented below:

domain_name -> nginx_ip_address -> wordpress_blog_ip_address

Where when a user visits "/blog", nginx forwards the request to a seperate ip address of a machine running a wordpress blog.

The problem is that when the user clicks on a post in the blog, the url will show as: "wordpress_blog_ip_address/post" and not "domain_name/blog/post". How can I fix this?

My current nginx file is below:

server {
    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /blog {
    proxy_pass http://new_ip_address/;
      proxy_set_header Host $host;
    }
}
  • 写回答

2条回答 默认 最新

  • doushi5913 2016-01-24 08:57
    关注

    It might be that wordpress is configured to use wordpress_blog_ip_address/ as a absolute url, and all url wordpress return will start with wordpress_blog_ip_address/. To change this absolute url, in wp-config.php, set WP_SITEURL to be dynamically generated, i.e.:

    define( 'WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/' );
    

    and the same for WP_HOME, WP_CONTENT_URL, WP_PLUGIN_URL and other field containing absolute url. ( use search feature in your editor. )

    Source: https://codex.wordpress.org/Editing_wp-config.php#WordPress_address_.28URL.29

    评论

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn