Proxy pass makes router->redirect from HTTPS to HTTP only

sjiamnocna
Member | 28
+
0
-

Hi,
We got app (Nette 3.x) and our admin decided to put two Nginx proxies before PHPFPM 8 container. Everything works (including links) until redirect after login made with Nette Forms. Action onSuccess contains `php $this->redirect(‘:Account:Dashboard:default’); ` and it breaks HTTPS and redirects the page from HTTPS to HTTP, no idea why.

HTTP is quite problem…

Any idea how to make this work?

Marek Bartoš
Nette Blogger | 1212
+
+1
-

Have you checked https://doc.nette.org/…onfiguration#… ?

To quickly verify if it's the problem, you can simply configure all addresses are from the proxy. But you should use only range of addresses used by the server.

http:
	proxy:
		- 0.0.0.0/0
		- ::/0

Last edited by Marek Bartoš (2023-09-02 01:17)

pn-pm
Member | 13
+
0
-

sjiamnocna wrote:

Hi,
We got app (Nette 3.x) and our admin decided to put two Nginx proxies before PHPFPM 8 container. Everything works (including links) until redirect after login made with Nette Forms. Action onSuccess contains `php $this->redirect(‘:Account:Dashboard:default’); ` and it breaks HTTPS and redirects the page from HTTPS to HTTP, no idea why.

HTTP is quite problem…

Any idea how to make this work?

I mangad to proceed by adding this to end of Bootstrap.php as suggested by man on webhosting company, it was redirectin g me to https://{domain}:80/{URI} which was breaking the SSL

if ('https' === getenv('HTTP_X_FORWARDED_PROTO')) {
 \Nette\Http\Url::$defaultPorts['https'] = (int) getenv('SERVER_PORT');
}

Last edited by pn-pm (2023-10-02 14:17)