So I recently setup a forum on Ubuntu 16 running nginx. Now the forum loads fine and everything but whenever I try to login, post, etc I get the error: The requested resource was not found. For some reason it can't find api.php (I think this is the issue)
This is my nginx config:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name (My forums web address);
root /var/www/html;
index index.php index.html index.htm;
charset utf-8;
location /forums { try_files $uri $uri/ /index.php?$query_string; }
location /forums/api { try_files $uri $uri/ /api.php?$query_string; }
location /forums/admin { try_files $uri $uri/ /admin.php?$query_string; }
location /forums/flarum {
deny all;
return 404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# the fastcgi_pass path needs to be changed accordingly when using CentOS
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_PROXY "";
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~* \.html$ {
expires -1;
}
location ~* \.(css|js|gif|jpe?g|png)$ {
expires 1M;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types application/atom+xml
application/javascript
application/json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
#text/html -- text/html is gzipped by default by nginx
text/plain
text/xml;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
location ~ /\.ht {
deny all;
}
}