Make CodeIgniter work behind apache with nginx as intermediary |
Hi
I've installed latest Apache, PHP7 and codeigniter in a Ubuntu 17.04 server, which has a static IP (eg: 10.20.30.40) I'm on a big corporative LAN and now this codeigniter app needs to be accessed from outside (internet) Tere's an intermediary nginx server (which I cannot access) that redirects everything from outside (internet) to my server So: http://www.subdomain.company.xxx/ci/index.php/test should load exactly the same as http://10.20.30.40/ci/index.php/test But only the local url works fine When I call from outside (or using anon proxy from internet) I get the codeigniter 404 page (not even the custom 404 apache errorpage I've set) There's no .htaccess nor config change made. It is just a base codeigniter install for testing this Any ideas? Thanks a lot in advance,
Enrique
https://beza.com.ar
08-02-2017, 05:23 PM
(This post was last modified: 08-02-2017, 05:28 PM by natanfelles. Edit Reason: ;) )
If you can see the CodeIgniter 404 it looks that you need configure your Base URL.
PHP Code: $config['base_url'] = $_SERVER['HTTP_HOST'] == '10.20.30.40' ? 'http://10.20.30.40/ci/' : 'http://www.subdomain.company.xxx/ci/';
Hi @natanfelles
Thanks for the reply. I've changed base_url config to that but the behaviour is the same. Now, one thing I've noticed debugging variables with xdebug 1. When I call http://10.20.30.40/ci/ this variable gets the following value and page works fine $_SERVER['REQUEST_URI'] = string '/ci/' (length=5) 2. When I call http://subdomain.company.xxx/ci/ the same variable gets the following value and page throws CI's 404 $_SERVER['REQUEST_URI'] = string '//ci/' (length=5) (note //ci/ with double bar) 3. If I load http://10.20.30.40//ci/ (note double bar) I get CI's 404 Maybe something related to $_SERVER['REQUEST_URI'] ? Lemme know if you would need all the debugged variables Thanks
Enrique
https://beza.com.ar
Finally solved by setting uri_protocol = PATH_INFO
application/config/config.php PHP Code: $config['base_url'] = $_SERVER['HTTP_HOST'] == '10.20.30.40' ? 'http://10.20.30.40/ci/' : 'http://www.subdomain.company.xxx/ci/'; and .htaccess like Code: RewriteEngine On Now it is working perfect locally and loaded from Internet
Enrique
https://beza.com.ar |
Welcome Guest, Not a member yet? Register Sign In |