Hey everyone! I've been using flarum with apache for quite sometime and now that I'm diving into nginx I find myself unable to make it work.
I have a vhost called 'forum' that has the exact code as the Installation instructions with a few additions like listening on port 81 and pointing my root to /var/www/html/forum. The code is the following:
server {
listen 81 default_server;
listen [::]:81 default_server;
access_log /var/log/nginx/access_log combined;
index index.php index.html index.htm index.nginx-debian.html
server_name _;
root /var/www/html/forum;
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; }
location /flarum {
deny all;
return 404;
}
location ~* \.php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability
fastcgi_index index.php;
}
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/plain
text/xml;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}
What I did on my default vhost is set a proxy_pass the following way:
location /forum/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300;
proxy_pass http://listen.moe:81/;
}
And lastly, on my config.php I configured the the url parameter like
'url' => 'https://listen.moe/forum',
But whenever I head to https://listen.moe/forum all I'm getting is Cannot GET https://listen.moe/
Any ideas where I'm messing up? I've been at this for a few hours and I can't seem to find a solution.
Thank you very much!