0

Problem summary

I'm trying to setup a reverse proxy (apache 2.4.29 Ubuntu) with a Symfony4.1.8 server. Where the end user goes to the webserver, the webserver reverse-proxies the request to the internal webserver (which is running on 127.0.0.1:4785), then can use this web application.

The initial request works, but after a 302 redirection (to the login page) it doesn't rewrite the url. (localhost/u/ => reverse proxies => localhost:4785/ => symfony redirects to login page (302) => end user gets localhost/login . Stops working here)

Background info

  • OS: Ubuntu18.04
  • Apache version: 2.4.29
  • Symfony version: 4.1.8 (running in dev mode)

Tried with, without "ProxyPreserveHost on/off". Remove trailing slashes, with trailing slashes (as documented in the official Apache 2.4 documentation) => a.e. : ProxyPass /u/ http://127.0.0.1:4785/ but also ProxyPass /u http://127.0.0.1:4785

Added "TRUSTED_PROXIES=127.0.0.1,localhost" to .env file adjusted public/index.php as suggested on this page: https://symfony.com/doc/current/deployment/proxies.html

Code

apache vhost conf file.

<VirtualHost *:80>
#       DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

#    ProxyRequests on
#    <Proxy *>
#        Order deny,allow
#        Allow from all
#    </Proxy>

    ProxyPreserveHost On

    ProxyPass /u/ http://127.0.0.1:4785/
    ProxyPassReverse /u/ http://127.0.0.1:4785/
</VirtualHost>

Symfony console output:

Press Ctrl-C to quit.
[Wed Feb  6 11:02:24 2019] 127.0.0.1:39164 [302]: /
[Wed Feb  6 11:05:02 2019] 127.0.0.1:39304 [302]: /

Final question

How do i get the reverse proxy working after redirecting? Is the "mistake" in the Symfony application or the Apache2 config? Thank you in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.