【问题标题】:Wrong URL for Apache2 with Proxypass and Nginx as backend for Symfony使用 Proxypass 和 Nginx 作为 Symfony 后端的 Apache2 的 URL 错误
【发布时间】:2017-04-25 09:23:16
【问题描述】:

我有问题;-)

我们有:

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

问题是静态文件,如 CSS/图像 ....

我们得到:

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

代替:

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

在我们的 Apache2.2 中我们使用:

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

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

Symfony 应用程序不知道它是通过 Apache ProxyPass 包含的,所以我的问题是,我必须在哪里更改配置。在 Apache2 或 Nginx 或 Symfony 上? :-)

非常感谢 :-) 库丹尼

【问题讨论】:

    标签: nginx reverse-proxy apache2.2 symfony-3.2


    【解决方案1】:

    您可以使用proxy_set_header

    有关更多详细信息,请参见此处:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header 或在此处查看示例用例: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;
      }
    }
    

    【讨论】:

    • 您好,感谢您的回复。我们找到了解决问题的相同方法。
    猜你喜欢
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-18
    • 1970-01-01
    相关资源
    最近更新 更多