[Bug]: NGINX - Cannot GET / #528

Closed
opened 2026-02-20 01:05:03 -05:00 by deekerman · 8 comments
Owner

Originally created by @RocketRammer on GitHub (Jul 11, 2022).

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

Originally created by @RocketRammer on GitHub (Jul 11, 2022). ### 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
deekerman 2026-02-20 01:05:03 -05:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Lanjelin commented on GitHub (Jul 11, 2022):

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

@Lanjelin commented on GitHub (Jul 11, 2022): 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
Author
Owner

@RocketRammer commented on GitHub (Jul 11, 2022):

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

image

@RocketRammer commented on GitHub (Jul 11, 2022): Ah interesting. Tested and progress.. that then gives a never ending loading wheel: ![image](https://user-images.githubusercontent.com/26411043/178293739-f5081c25-9321-4bb3-86d2-9885134bca5a.png)
Author
Owner

@Lanjelin commented on GitHub (Jul 11, 2022):

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;
@Lanjelin commented on GitHub (Jul 11, 2022): 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; ```
Author
Owner

@RocketRammer commented on GitHub (Jul 11, 2022):

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.

@RocketRammer commented on GitHub (Jul 11, 2022): 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.
Author
Owner

@Lanjelin commented on GitHub (Jul 11, 2022):

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 / {
...
@Lanjelin commented on GitHub (Jul 11, 2022): 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](https://github.com/advplyr/audiobookshelf#nginx-reverse-proxy), it needs to be hosted directly at the root of the domain or a subdomain ``` listen 443 ssl; server_name <sub>.<domain>.<tld>; location / { ... ```
Author
Owner

@RocketRammer commented on GitHub (Jul 11, 2022):

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.

@RocketRammer commented on GitHub (Jul 11, 2022): 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.
Author
Owner

@RocketRammer commented on GitHub (Jul 11, 2022):

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.

@RocketRammer commented on GitHub (Jul 11, 2022): 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.
Author
Owner

@advplyr commented on GitHub (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 commented on GitHub (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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/audiobookshelf#528
No description provided.