账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    nginx反向代理Apache伪静态
    81
    0
    server {
      listen       80;
      server_name  test.com;
      root   "D:/test.com/";
      location / {
        index  index.html index.htm index.php;
      }
      location ~ \.php(.*)$ {
        rewrite ^/(.*)$ index.php/$1 break;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass  http://test.com:8080;
      }
    }

    我想通过nginx的80端口反向代理到apache的8080端口,怎么实现.php的伪静态呢?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 在Nginx中,反向代理Apache服务器是为了提高系统的性能和稳定性。以下是如何在Nginx中使用Apache伪静态进行反向代理的步骤:

      1. 首先,你需要在Nginx的配置文件中启用反向代理功能。在Nginx的配置文件中,可以使用location指令来设置反向代理的规则。

      nginx location / { proxy_pass http://你的Apache服务器IP地址:8080; proxy_set_header Host $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; }

      1. 在Nginx的配置文件中,你还需要设置Apache服务器的配置文件。在Apache的配置文件中,可以使用VirtualHost指令来设置反向代理的规则。

      apache VirtualHost *:80 { proxy_pass http://你的Apache服务器IP地址:8080; proxy_set_header Host $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; }

      1. 在Nginx和Apache的配置文件中,你需要将Apache服务器的IP地址和8080端口设置为反向代理服务器的IP地址和80端口。

      nginx location / { proxy_pass http://yourApache服务器IP地址:8080; proxy_set_header Host $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; }

      1. 重启Nginx和Apache服务器,使配置生效。

      bash sudo systemctl restart nginx sudo systemctl restart apache2

      以上就是在Nginx中使用Apache伪静态进行反向代理的步骤。需要注意的是,反向代理可能会增加服务器的负载,因此在设置反向代理时,应根据实际情况进行调整。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部