-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
uri->getHost() #815
Comments
IncomingRequest class -> detectURI() |
Trusting either of those to be safe from malicious user intent is bad, but of the two, SERVER_NAME is a bit safer from what I understand. Though, as this post points out, at least under Apache, it can still be potentially set to what the user wants it to be. The best bet is to not use that, and have an environment variable set that tells you what server your on, or environment (production? development?), etc, instead of relying on the the server to tell you. |
It is true but as long as your app runs only on one domain name or should runs exactly the same on all domains. |
It can still function the same on all domains safely if you use the That said, I can't recall if this is something I implemented or brought over from CI3 so I might need to revisit it since it's not pulling in the sub-domain. Also - note to self - I need to ensure redirect is using base_url since it's manually set by the developer to help protect against phishing attacks when someone does use HTTP_HOST or SERVER_NAME. |
Hey, @lonnieezell What about to enable the usage of an array as App::$baseURL ? Then auto get it by the |
Otherwise, what will be the best way to set the App::$baseURL if an app is available in many domains? Let it empty or |
I'm a little confused on usage here. But there is one problem if I'm understanding you correctly: both As for the best way to handle an app that works under multiple domains - hard to say without knowing if you controlled all of the domains or if it was to be installed by multiple users (like with a CMS). Even then, I don't know I can truly say there is any "best" way. Out of the box, we have to be as secure as possible and for most applications build be freelancers and agencies, I would say this method works well. For other cases like you're mentioning here, people might have to balance their business needs and security. Heck, people have been using |
Thanks for reply. The usage I think is having multiple Virtual Hosts pointing the root dir to the same CI public dir. On CI 3 is possible to use an conditional like: $domain = strtolower($_SERVER['HTTP_HOST']);
switch($domain)
{
case 'admin.site.com':
$config['base_url'] = 'https://admin.site.com/';
break;
case 'api.site.com':
$config['base_url'] = 'http://api.site.com/';
break;
default:
$config['base_url'] = 'http://site.com/';
break;
} This prevent the default usage of Then, now in CI 4 having the possibility to use routes by hostnames and subdomains I thinked if is possible to check it by default. |
You could still do that same block in the constructor of Config\App.php:
|
Oh, yeah. Thank you! Sorry for this untested and badly thought out question. |
I'm trying to get host name from class which implements FilterInterface...
In before() method I'm using RequestIterface to get hostname:
I've got in $_SERVER array:
SERVER_NAME: www.domain.com
HOST_NAME: adm.domain.com
so I thought host returned by ->getHost() will be adm.domain.com but it is www.domain.com instead...
I'm using php7.1.11 and the newest nginx.
Nginx is configured with multiple names of server_name for the same directory.
The text was updated successfully, but these errors were encountered: