2017-04-25 1 views
1

J'ai un problème ;-)URL incorrect pour Apache2 avec PROXYPASS et Nginx comme back-end pour Symfony

nous avons:

Apache2 -> ProxyPass -> intern.domain.foo/ -> Ngnix -> PHP

Le problème sont des fichiers statiques comme CSS/images ....

Nous obtenons:

https://foo.example.com/foobar/images/bla.png

au lieu de:

https://foo.example.com/foobar/iframes/images/bla.png

Dans notre Apache2.2 nous utilisons:

... 
# ProxyPass to Appint Iframes 
ProxyPass /iframes  http://intern.domain.foo 
<Location /iframes> 
    ProxyPassReverse http://intern.domain.foo 
</Location> 
.... 

Sur Nginx:

server { 
    listen *:80; 
    server_name   intern.domain.foo; 

    root /opt/webapps/iframes/web/; 
    index index.php; 

    location/{ 
    root  /opt/webapps/iframes/web/; 
    index  index.html index.htm index.php; 
    try_files $uri /app.php$is_args$args; 

    } 

    location ~ ^/app\.php(/|$) { 
    root   /opt/webapps/iframes/web/; 
    include  /etc/nginx/fastcgi_params; 

    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_connect_timeout 3m; 
    fastcgi_param DOCUMENT_ROOT $realpath_root; 
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
    fastcgi_read_timeout 3m; 
    fastcgi_send_timeout 3m; 
    fastcgi_split_path_info ^(.+\.php)(/.*)$; 
    internal; 
    } 
} 

L'application Symfony ne sait pas, que est inclus via Apache ProxyPass, donc ma question est, où je dois changer la config. Sur Apache2 ou sur Nginx ou sur Symfony? :-)

Merci beaucoup :-) cu denis

Répondre

0

vous pouvez le faire avec proxy_set_header:

Pour plus de détails regardez ici: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header ou voir ici un cas d'utilisation exemple: Configure Nginx with proxy_pass

server { 
    listen 80; 
    server_name example.com; 
    location/{ 
    proxy_pass  http://main; 
    proxy_set_header Host   $host; 
    proxy_set_header X-Forwarded-For $remote_addr; 
    } 
} 
+0

Salut, merci pour la réponse. Nous avons trouvé la même manière de résoudre le problème. –