简体   繁体   English

nginx代理通过php和相对路径传递

[英]nginx proxy pass with php and relative path

My problem seem to be simple ... 我的问题似乎很简单...

I have 1 server on my lan 192.168.0.2 with a root path /var/www/ (apache2) and 1 domain example.com (nginx) and 1 subdomain bug.example.com (nginx) 我的局域网192.168.0.2上有1个服务器,其根路径为/ var / www /(apache2)和1个域example.com(nginx)和1个子域bug.example.com(nginx)

and want only a proxy beetween http://192.168.0.2/bugs/ --->> http://bug.example.com/ 并且只需要http://192.168.0.2/bugs/ --->> http://bug.example.com/的代理

I use a bugtracker (Mantis) in the root directory like this /var/www/bugs 我在/ var / www / bugs这样的根目录中使用Bugtracker(Mantis)

this config work : 这个配置工作:

server {

    listen 80;
    server_name bug.example.com;

    location / {
            proxy_pass   http://192.168.0.2/bugs/;
   }
 }

But i don't have access to css or images ... 但是我无法访问CSS或图像...

Css : CSS:

<link rel="stylesheet" type="text/css" href="http://192.168.0.2/bugs/css/default.css" />

image : 图片 :

<link rel="shortcut icon" href="/bugs/images/favicon.ico" type="image/x-icon" />

I have test a LOT OF configuration with "proxy_set_header" , "proxy_redirect" , "rewrite" ... but never with success :( 我已经用“ proxy_set_header”,“ proxy_redirect”,“ rewrite”测试了很多配置...但是从没有成功:(

Can anybody help me ? 有谁能够帮助我 ?

This is a PHP problem. 这是一个PHP问题。 The site doesn't know for the redirect... As I see, it renders the CSS files with full path 192.168.0.2/bugs... Try to find a solution how to handle this in PHP, not nginx. 该站点不知道重定向...如我所见,它使用完整路径192.168.0.2/bugs呈现CSS文件...尝试找到一种解决方案,该方法如何在PHP中处理此问题,而不是nginx。

Look for a configuration setting for HOST_NAME or similar in Mantis. 在螳螂中寻找HOST_NAME或类似的配置设置。

As for images, changing to bugs.site.com/bugs should fix them.. Otherwise you'll need to let Mantis know that it has no virtual path /bugs. 至于图像,更改为bugs.site.com/bugs应该可以解决它们。否则,您需要让Mantis知道它没有虚拟路径/ bugs。 Is it an Apache server behind? 是背后的Apache服务器吗?

UPDATE: Actually you could try stripping HOST header and sending it modified as 'bugs.site.com'... It all depends on the actuall web server/Mantis/ configuration .. 更新:实际上,您可以尝试剥离HOST标头,并将其修改为“ bugs.site.com”发送。这完全取决于实际的Web服务器/ Mantis /配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM