Skip to content

Why is $_SERVER['SERVER_PORT'] always 80, even when I open https://mypage.ddev.site:443 ? #7083

Answered by rfay
JayQ1982 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @JayQ1982 - This is the same situation as on a normal server environment, where you have a reverse proxy in front of your web server. In DDEV, the ddev-router accepts traffic on 443 and proxies it to the ddev-webserver on port 80. If you want to know the actual URLs in any environment, you'll want to use the X_ variables, in your case HTTP_X_FORWARDED_PORT and HTTP_X_FORWARDED_PROTO:

$_SERVER['HTTP_X_FORWARDED_FOR']
$_SERVER['HTTP_X_FORWARDED_PROTO']
$_SERVER['HTTP_X_FORWARDED_PORT']

More architecture detail in https://ddev.readthedocs.io/en/stable/users/usage/architecture

This article might help too, https://serverfault.com/questions/256191/getting-correct-server-port-to-php-fpm-thro…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JayQ1982
Comment options

Answer selected by JayQ1982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants