Welcome Guest, Not a member yet? Register   Sign In
Make CodeIgniter work behind apache with nginx as intermediary

I've installed latest Apache, PHP7 and codeigniter in a Ubuntu 17.04 server, which has a static IP (eg:
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
should load exactly the same as

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,

(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'] == '' '' '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 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 (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


Finally solved by setting uri_protocol = PATH_INFO


PHP Code:
$config['base_url'] = $_SERVER['HTTP_HOST'] == '' '' 'http://www.subdomain.company.xxx/ci/'
$config['index_page'] = '';
$config['uri_protocol'] = 'PATH_INFO'

and .htaccess like

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Now it is working perfect locally and loaded from Internet

Theme © iAndrew 2016 - Forum software by © MyBB