js映射 nginx_通过Nginx中的proxy_redirect替换图像和JavaScript绝对路径

本文描述了一个问题,即Nginx作为反向代理到运行在8080端口的Apache服务器,但HTML中的图像和JavaScript路径为绝对路径,导致资源加载错误。提出了使用proxy_redirect解决重定向问题,以及考虑使用ngx_http_sub_module模块替换绝对路径的解决方案,以更干净地处理这种情况。
摘要由CSDN通过智能技术生成

I have a scenario as follows.

Nginx is being used as a reverse proxy to a apache server listening at port 8080. nginx is running at port 80. There is a wsgi application which is being run by the apache server.

Now, I have added a proxy_pass to the nginx configuration such that whatever requests come to localhost/ (nginx port is the default port 80) they get redirected to localhost:8080.

Here is an excerpt from the nginx conf file:

server {

listen 80;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_set_header Host $host;

location {

proxy_pass http://localhost:8080/

proxy_redirect http://localhost/ http://localhost:8080/

}

}

I have added the proxy redirect to take care of any redirects from the apache server so that any req

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值