Skip to content
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

Wildcard vhosts on Nginx and the hive HOST key dont behave. #245

Closed
ethanpil opened this issue Feb 9, 2018 · 1 comment
Closed

Wildcard vhosts on Nginx and the hive HOST key dont behave. #245

ethanpil opened this issue Feb 9, 2018 · 1 comment

Comments

@ethanpil
Copy link

ethanpil commented Feb 9, 2018

Had an issue a few days ago where I migrated an old project onto Nginx. The configuration for the project is a wildcard vhost. Had it running in apache fine for a few years and replicated the configuration in nginx.

The nginx conf file for the vhost looks something like this server *.domain.com {...

In my F3/PHP code, I parse out the subdomain from $f3->get('HOST') and take a specific action. After the change this stopped working. Seems that I was getting *.domain.com as the return value for $f3->get('HOST') instead of sub.domain.com

Ended up changing my code to parse from $_SERVER['HTTP_HOST'] instead of $f3->get('HOST')

I can submit a PR but I figured it warrants some discussion here. Not sure the right thing to do. Maybe we should add one more key to retain backward compatibility?

@xfra35
Copy link
Member

xfra35 commented Feb 9, 2018

There was already a discussion about this: bcosca/fatfree#520

HTTP_HOST can't be trusted by the framework because it's coming from the client while SERVER_NAME is coming from the server.

So you should fix SERVER_NAME.

You can do it :

$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
$f3 = require('lib/base.php');
// etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants