-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$_SERVER['HTTP_HOST']
doesn't exist when requesting via HTTP/3 on nginx
#13021
Comments
$_SERVER['HTTP_HOST']
doesn't exist when requesting via HTTP/3 on _nginx_$_SERVER['HTTP_HOST']
doesn't exist when requesting via HTTP/3 on nginx
Seems to be an issue on nginx's side, see nginx-quic/nginx-quic#3 |
There is a trac ticket linked from above mentioned github issue, which is resolved as "invalid" https://trac.nginx.org/nginx/ticket/2281 (I am no sapi expert either ;)) |
This is not a php issue indeed, but let's leave it open for a while once other folks come back from holidays. |
Please note that this is not a solution at all: Unless nginx starts providing the request's authority as the |
Yes, I understand that. Precisely because Now it seems that nginx doesn't want to change this, but recommends using |
By default nginx only provides the request headers to PHP, without using In other words: PHP can only work with the data nginx provides to it. You might or might not be able to convince the nginx team to change
This would require you to change your script to make use of the |
So as it was said, FPM does not get any info from nginx and most clients won't send Host header with HTTP/3 but instead the I think ideally you should set REMOTE_HOST and use that instead. I think it would be reasonable to have We could potentially add small change to FPM to take REMOTE_HOST from HTTP_HOST if not set. That would make it more usable for configuration using HTTP/1.1 and HTTP/2. I just checked and we already deal with some headers and changing some other variable so this wouldn't be anything special and pretty easy to do. |
Ok so I just sent a patch to nginx-devel so will see what they think: https://mailman.nginx.org/pipermail/nginx-devel/2024-January/3CQEHII5QU2BTQ7L7DAVCBWK3OQS3GU6.html |
Forgot to send update here. So this was not such a good idea at the end as REMOTE_HOST has a different meaning and it's more a legacy things so not good for this. Considering https://mailman.nginx.org/pipermail/nginx-devel/2024-January/LCIUMLKCM2EBMEMTU3KXMW74AP2C4FYZ.html , nginx does it (emulates host header) already for HTTP/2 so the best solution would be if they did for HTTP/3 as well. There's nothing we can do on PHP side so closing this. |
Thank you for communicating with the nginx staff. Looking forward to changes in nginx. |
Description
I'm using nginx 1.25.3 + PHP 8.3.0.
When requesting via HTTP/2, I can get
$_SERVER['HTTP_HOST']
correctly. But when requesting via HTTP/3,HTTP_HOST
doesn't exist in the array.Will PHP officially fix this? Is there any other solution besides replacing
HTTP_HOST
withSERVER_NAME
?PHP Version
PHP 8.3.0
Operating System
Debian 12.2 64-bit
The text was updated successfully, but these errors were encountered: