Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: NGINX - Cannot GET / #828

Closed
RichardMawdsley opened this issue Jul 11, 2022 · 8 comments
Closed

[Bug]: NGINX - Cannot GET / #828

RichardMawdsley opened this issue Jul 11, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@RichardMawdsley
Copy link

Describe the issue

Hi There,

I'm unable to access the webpage via NGINX. I'm able to access it locally via IP:PORT

This is my NGINX config relating to this:

server {

listen [::]:443 ssl http2;
listen 443 ssl http2;;
server_name REDACTED;

#SSL Settings
ssl_session_timeout 30m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_certificate /etc/letsencrypt/live/REDACTED.ddns.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/REDACTED.ddns.net/privkey.pem;
ssl_session_cache shared:SSL:10m;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM';

#Added Security Settings
proxy_hide_header X-Powered-By;
add_header X-Content-Type-Options "nosniff" always;
add_header Strict-Transport-Security "max-age=16416000; includeSubdomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header 'Referrer-Policy' 'no-referrer';
add_header X-Xss-Protection "1; mode=block" always;

#SSL Stapling
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/REDACTED.ddns.net/fullchain.pem;

#Set error log and content policy
add_header Content-Security-Policy "REDACTED.ddns.net";
error_log /var/log/nginx/REDACTED.ddns.net.error.log;
access_log /var/log/nginx/REDACTED.ddns.net.access.log;

#Set Password authentication on pages
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;

          location /audiobookshelf {
              proxy_pass http://127.0.0.1:7331;
              proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
              proxy_set_header  X-Forwarded-Proto $scheme;
              proxy_set_header  Host              $host;
              proxy_set_header Upgrade            $http_upgrade;
              proxy_set_header Connection         "upgrade";
              proxy_http_version                  1.1;
              proxy_redirect                      http:// https://;
          }

}

Included my various SSL/security bits above for the case they're related. I use NGINX currently for a whole host of other services which are all working fine.

When browsing to https://FQDN/audiobookshelf I simply get:

"Cannot GET /audiobookshelf"

Inside the access.log I see:

"GET /audiobookshelf HTTP/2.0" 404 153 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"

Debug logs from AudioBookShelf are unremarkable:

=== Starting Server ===
2022-07-11 11:15:46
INFO
[Server] Init v2.0.23
2022-07-11 11:15:46
INFO
[DB] 0 Library Items Loaded
2022-07-11 11:15:46
INFO
[DB] 0 Libraries Loaded
2022-07-11 11:15:46
INFO
[DB] 0 Collections Loaded
2022-07-11 11:15:46
INFO
[DB] 0 Authors Loaded
2022-07-11 11:15:46
INFO
[DB] 0 Series Loaded
2022-07-11 11:15:46
INFO
[DB] 1 Users Loaded
2022-07-11 11:15:46
INFO
[BackupManager] 0 Backups Found
2022-07-11 11:15:46
INFO
[BackupManager] Auto Backups are disabled
2022-07-11 11:15:46
INFO
[LogManager] Init current daily log filename: 2022-07-11.txt
2022-07-11 11:15:46
INFO
Listening on http://0.0.0.0:7331
2022-07-11 11:45:29
INFO
[Server] Socket Connected REDACTED-UNSURE-IF-UNIQUE

Steps to reproduce the issue

  1. Install on Linux using commands on setup page (not docker).
  2. Configure NGINX

Audiobookshelf version

v2.0.23

How are you running audiobookshelf?

Built from source

@RichardMawdsley RichardMawdsley added the bug Something isn't working label Jul 11, 2022
@RichardMawdsley RichardMawdsley changed the title [Bug]: Cannot GET / [Bug]: NGINX - Cannot GET / Jul 11, 2022
@Lanjelin
Copy link

Try changing

location /audiobookshelf {
    proxy_pass http://127.0.0.1:7331;

To

location /audiobookshelf/ {
    proxy_pass http://127.0.0.1:7331/;

http://nginx.org/r/proxy_pass

@RichardMawdsley
Copy link
Author

Ah interesting. Tested and progress.. that then gives a never ending loading wheel:

image

@Lanjelin
Copy link

If you open the console, my guess is that’s there a lot of 404 errors to yoursomain.tld/audiobookshelf/…stuff…
I usually just add another subdomain instead of subfolders when the application doesn’t listen on a subdirectory.

It is possible though to get working, and my guess is that you need a subfilter as well.
https://nginx.org/r/sub_filter

Not in front of my computer at the moment, or I’d test myself, but hopefully the following is close.

sub_filter 'https://yourdomain.tld/audiobookshelf/' 'https://$host/';
sub_filter_once off;

@RichardMawdsley
Copy link
Author

Thanks @Lanjelin, appreciate your help.

I'm not familiar with the sub_filter, I put your example (changing domain) inside the current location block but no change, still the loading circle.

@Lanjelin
Copy link

I'm sorry, I had it backwards, subfolder to subdomain.
The server (and clients) has to support subirectory (aka. URL base).

As per the Reverse Proxy Setup, it needs to be hosted directly at the root of the domain or a subdomain

listen 443 ssl;
server_name <sub>.<domain>.<tld>;
location / {
...

@RichardMawdsley
Copy link
Author

Ah gotcha, I don't think I'll be able to do that in this instance as I'm using ddns for the domain name (not one I own) thus can't do subdomains.

@RichardMawdsley
Copy link
Author

Is there a way to set the 'base' in AudioBookShelf? - by that I mean in this case what would be /audiobookshelf/ for myself. Every other app I host has this setting, seems like its missing here.

@advplyr
Copy link
Owner

advplyr commented Jul 12, 2022

Subfolders are not supported yet so you will need to use a subdomain for your reverse proxy. There is a ticket open for subfolder support #385 and it will get implemented at some point but it's not a quick update unfortunately.

@advplyr advplyr closed this as completed Jul 12, 2022
Oasis256 pushed a commit to Oasis256/StoryTeller that referenced this issue Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants