Kris
August 4, 2019, 10:05pm
1
Good day folks;
I’m running ghost alongside a static folder that needs to be able to respond to GET from a client downloader. This has worked in the past and I do not know what would cause this to break at this time.
The folder that is causing 404 errors (from ghost, not nginx) is located at:
/var/www/launcher
My ghost sites-enabled confs are below:
www.centerofthemultiverse.net.conf
server {
listen 80;
listen [::]:80;
server_name www.centerofthemultiverse.net;
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
allow all;
}
location /launcher {
autoindex on;
}
client_max_body_size 50m;
}
www.centerofthemultiverse.net-ssl.conf
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.centerofthemultiverse.net;
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
ssl_certificate /etc/letsencrypt/www.centerofthemultiverse.net/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/www.centerofthemultiverse.net/www.centerofthemultiverse.net.key;
include /etc/nginx/snippets/ssl-params.conf;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
allow all;
}
location /launcher {
autoindex on;
}
client_max_body_size 50m;
}
Any Ideas?
Please let me know what other information would be helpful.
Cheers!
Hannah
August 6, 2019, 2:21pm
2
I believe you’re missing a root declaration:
location /launcher {
root /var/www/launcher;
autoindex on;
}
The location /launcher
refers to the request URL, nginx doesn’t know about folders on disk unless you tell it about them.
As it is, the root has been set at the top of the config:
root /var/www/ghost/system/nginx-root;
It might be that you want to drop that line into the location ~ /.well-known {}
block (although I’ve not tested that before) and set your global root to /var/www/
.
Kris
August 6, 2019, 3:32pm
3
Thanks much for your reply!
Would you mind formatting this into the code blocks I provided, please? I’m having a bit of a hard time parsing what you are advising as to what changes need to be made and tested and I don’t want to mangle things further.
Also, when you say ‘set global root’ I assume you mean in the base nginx.conf? If so, I’ll need to write out an entire server block as current config does not have one.
Cheers!
Hannah
August 6, 2019, 3:50pm
4
The fix is to swap your location blocks that look like this
location /launcher {
autoindex on;
}
To this:
location /launcher {
root /var/www/launcher;
autoindex on;
}
When I say “global root”, I mean the line I mentioned:
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh )
It’s global to the server configuration file. I’m not talking about nginx.conf.
Kris
August 6, 2019, 4:24pm
5
I think I got it now, thank you for clarifying!
Like so?:
server {
listen 80;
listen [::]:80;
server_name www.centerofthemultiverse.net;
root /var/www/
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
allow all;
}
location /launcher {
root /var/www/launcher;
autoindex on;
}
client_max_body_size 50m;
}
Hannah
August 6, 2019, 5:12pm
6
nginx’s root directive tells the current scope (server or location block) where to look on disk.
The simplest solution is just to update your location /launcher {}
block to have the correct root.
You can also change all the other roots around as you have done.
I would make one change at a time, and test them, until you get the behaviour you want.
Kris
August 6, 2019, 6:25pm
7
Good news: No longer getting the ghost 404.
Bad news: Now I am getting the nginx 404
I think we are getting closer?
This result occurred by doing both proposed fixes. Both .conf are not set up like this - the blog still works, but still getting nginx 404:
server {
listen 80;
listen [::]:80;
server_name www.centerofthemultiverse.net;
root /var/www/;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
allow all;
}
location /launcher {
root /var/www/launcher;
autoindex on;
}
client_max_body_size 50m;
}
Kris
August 10, 2019, 4:33pm
8
Bumping - as said, the blog works but still getting 404 otherwise. Also getting 403 Forbidden when you omit the www on the address but that is a separate issue.
So, I ask - is this anything to do with how ghost configs nginx or is this strictly an nginx issue? Every nginx guide/resource I could find leads me to believe I have things configured properly so I am at a total loss at this point.
Kris:
location /launcher {
Shouldn’t it be /launcher/
if it’s a directory?
Kris
August 14, 2019, 5:37pm
10
Sadly, that did not seem to work:
This is the following blurb in both ssl/regular conf files
location ~ /.well-known {
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
allow all;
}
location /launcher/ {
root /var/www/launcher/;
autoindex on;
}
Kris
September 5, 2019, 6:20pm
11
Necrobump - still not been able to find an answer to why this is happening.
Kris
September 6, 2019, 7:20pm
12
Figured I should add my base config at this point, too:
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
Kris
September 6, 2019, 7:22pm
13
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.centerofthemultiverse.net;
root /var/www/;
ssl_certificate /etc/letsencrypt/www.centerofthemultiverse.net/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/www.centerofthemultiverse.net/www.centerofthemultiverse.net.key;
include /etc/nginx/snippets/ssl-params.conf;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
allow all;
}
location /launcher/ {
root /var/www/launcher/;
autoindex on;
}
client_max_body_size 50m;
}
Kris
September 6, 2019, 7:23pm
14
listen 80;
listen [::]:80;
server_name www.centerofthemultiverse.net;
root /var/www/;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
allow all;
}
location /launcher/ {
root /var/www/launcher/;
autoindex on;
}
client_max_body_size 50m;
}
Hannah
September 11, 2019, 4:50pm
15
You’re getting an nginx 404 because nginx cannot find the file you’re asking for.
What files are in the /var/www/launcher/ directory, and what URL are you using to request them?