Proxy pass doesn't redirect

Alles, was den Apache betrifft, kann hier besprochen werden.

Proxy pass doesn't redirect

Postby user12978319283 » 12. December 2019 07:45

I want to redirect all traffic from http to https. But I also want
`/grafana` to go to `https://localhost:3000/`

Port 80 and 443 is listening by apache2 and serves zabbix frontnend.

Port 3000 is listening by grafana-server.

apache2.conf - virtual host port 80

Code: Select all
        Redirect /      https://10.10.10.10/

        ProxyPass /grafana https://10.10.10.10:3000/
        ProxyPassReverse /grafana https://10.10.10.10:3000/



ssl.conf - virtual host port 443

Code: Select all
        SSLProxyEngine On
        SSLProxyVerify none
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
        SSLProxyCheckPeerExpire off
        ProxyPass /grafana https://10.10.10.10:3000/
        ProxyPassReverse /grafana https://10.10.10.10:3000/



But `/grafana` redirects to `https://10.10.10.10/login` instead of `https://10.10.10.10:3000/login`
.

Any suggestion?
user12978319283
 
Posts: 2
Joined: 12. December 2019 07:43
XAMPP version: 7.2
Operating System: ubuntu 16.04

Re: Proxy pass doesn't redirect

Postby Nobbie » 12. December 2019 10:44

Remove the 2 lines proxypass and proxypassreverse from the port 80 virtualhost, then try again (restart apache). And please show us the full virtualhosts, your description is about localhost, but instead you proxypass to 10.10.10.10, what is NOT localhost.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: Proxy pass doesn't redirect

Postby user12978319283 » 12. December 2019 11:15

Still same issue, the /grafana request goes to https://10.10.10.10/login instead of https://10.10.10.10:3000/login

Here is the complete virtual host config.

000-default.conf
Code: Select all
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect /      https://10.10.10.10/
</VirtualHost>


default-ssl.conf

Code: Select all
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile      /etc/apache2/certs/cert.crt
SSLCertificateKeyFile   /etc/apache2/certs/cert.key

SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass /grafana https://localhost:3000/
ProxyPassReverse /grafana https://localhost:3000/
</VirtualHost>
user12978319283
 
Posts: 2
Joined: 12. December 2019 07:43
XAMPP version: 7.2
Operating System: ubuntu 16.04

Re: Proxy pass doesn't redirect

Postby Nobbie » 12. December 2019 12:36

In your current configuration your proxypass is going to localhost (not to 10.10.10.10). Is 10.10.10.10 the same PC as localhost? Why do you a "Redirect" to "10.10.10.10", but your ProxyPass goes to localhost?

Clear the browser cache as well.
What happens if you enter https://localhost:3000/ in a browser?

And why do you use ProxyPass? Why not simply

Code: Select all
Redirect /grafana https://localhost:3000


Finally, all your VirtualHosts lack a ServerName, that may also be a reason for that behaviour. You have a port change between the frontend server and the backend server, usually Apache needs a ServerName to create the correct Locationheader in that scenario.

Perhaps you have to apply UseCanonicalPhysicalPort-Direktive and/or UseCanonicalName-Direktive in order to get the correct port in the URL. Currently Apache seems to evaluate Port 80 for the backend Server (what is wrong).
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 51 guests