Denny Fuchs
Denny Fuchs

Reputation: 11

Wrong URL for Apache2 with Proxypass and Nginx as backend for Symfony

I have a problem ;-)

we have:

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

The problem are static files like CSS/images ....

We get:

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

instead of:

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

In our Apache2.2 we use:

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

On 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;
  }
}

The Symfony app doesn't know, that it is included via Apache ProxyPass, so my question is, where I have to change the config. On Apache2 or on Nginx or on Symfony? :-)

Thanks a lot :-) cu denny

Upvotes: 1

Views: 725

Answers (1)

rabbl
rabbl

Reputation: 93

you can do this with proxy_set_header:

For more details look here: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header or see an example use-case here: 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;
  }
}

Upvotes: 1

Related Questions