nginx config incorrect
Hi.
I was getting 403 forbidden with nginx config described in docs. It is incomplete and was missing:
index index.php; directive.
centos7, using docker container for nginx and php7-fpm
Hi, thanks for the report!
What makes you think that this is incorrect? It seems to work for many people...
default nginx config doesn't have index index.php; and it tries to load index.html which doesn't exist and fails with 403 error.
There is a directive
fastcgi_index index.php;
@sandrodz , do you have this module enabled in nginx? -> ngx_http_fastcgi_module
@kulga
If you don't have index index.php; outside location directive, fastcgi_index index.php; inside location will never match.
I'm testing on official nginx docker image.
also this: http://stackoverflow.com/questions/30802025/what-is-fastcgi-index-in-nginx-used-for
Oh, yep. That makes sense. After checking, I have index placed before existing flarum nginx config.
But technically, this still isn't complete since root, server_name and listen are not included either. Except for those, we can't possibly predict them.
Perhaps
location / { try_files $uri $uri/ /index.php?$query_string; } location /api { try_files $uri $uri/ /api.php?$query_string; } location /admin { try_files $uri $uri/ /admin.php?$query_string; }
Changed to
listen port;
root /flarum/location; index index.php;
server_name domain.tld;
location / { try_files $uri $uri/ /index.php?$query_string; } location /api { try_files $uri $uri/ /api.php?$query_string; } location /admin { try_files $uri $uri/ /admin.php?$query_string; }
Well if you don't setup root, server_name and listen you will see the meaningful errors. But if you miss index index.php; you will just see bogus forbidden. threw me off for a sec.
but yeah, I think you should include the whole thing, and people will just edit relevant parts.
Fixed by adding .nginx.conf to flarum/flarum (https://github.com/flarum/flarum/commit/b4a09a072f32f1c0fe6d0cfd210e1ea05bf423f6), used from within an existing Nginx configuration.