mitchray / ample

A simple web browser client for Ampache
https://ample-player.vercel.app/
GNU Affero General Public License v3.0
63 stars 13 forks source link

Access denied on v.50.0 with nginx #37

Closed SimonHova closed 1 year ago

SimonHova commented 1 year ago

When running nginx and the newly made v.50.0, I get a 403/Forbidden page. Oddly enough, if I were to go to one of the subpages (http://myserver.com:5006/ample/smartlists for example) I can get to the login page, then I can click on the logo on the top left corner and get back to the home page without issue.

The error looks like it could be related to this Stack Overflow article; I too have a symlink from the public folder of Ampache back out to the root folder where ample is located.

mitchray commented 1 year ago

Does it work if you have a trailing slash?

http://myserver.com:5006/ample/ vs http://myserver.com:5006/ample

SimonHova commented 1 year ago

In Chrome, it seems to make no difference if I use trailing slashes or none. Though, if I leave it off, it adds the slash for me when loading the error page.

mitchray commented 1 year ago

Ah OK, did you update the index.php to index.html? https://github.com/mitchray/ample/wiki/NGINX-rewrite

SimonHova commented 1 year ago

Yes, file name was changed in the config.

On Tue, Nov 22, 2022, 6:24 PM Mitch Ray @.***> wrote:

Ah OK, did you update the index.php to index.html? https://github.com/mitchray/ample/wiki/NGINX-rewrite

— Reply to this email directly, view it on GitHub https://github.com/mitchray/ample/issues/37#issuecomment-1324361730, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGWV3X772LF2NW2XJW6XPLWJVI33ANCNFSM6AAAAAASGZTNJY . You are receiving this because you authored the thread.Message ID: @.***>

mitchray commented 1 year ago

If there is no further clues in browser console or nginx logs then I'm afraid I don't know why it wouldn't be working anymore

Hopefully if its affecting more nginx users they can chime in

mitchray commented 1 year ago

Only other thing I can think of is trying

location /ample {
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.html;
    }
}
SimonHova commented 1 year ago

Unfortunately, that did not work.

I tried the solution offered by the link and turned on autoindex, it just displays the index of the /ample/ folder.

   # for ample media player
   location /ample {
    autoindex on;
    if (!-e $request_filename) {
        rewrite ^(.*)$ /ample/index.html;
    }
   }

You had also mentioned showing the source; I hit ctrl+u from the home page that was not working, and a pretty basic nginx error page.

  | <html>
-- | --
  | <head><title>403 Forbidden</title></head>
  | <body bgcolor="white">
  | <center><h1>403 Forbidden</h1></center>
  | <hr><center>nginx</center>
  | </body>
  | </html>
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  |  

What's odd is that I go to the http://myserver:5006/ample/smartlists/ page, it loads the page normally, including a seemingly normal HTML page.

Then, I navigate back to the home page by clicking on the top left corner, and while it looks right on my screen, typing ctrl+u gives me the exact same page as the first one.

  | <html>
-- | --
  | <head><title>403 Forbidden</title></head>
  | <body bgcolor="white">
  | <center><h1>403 Forbidden</h1></center>
  | <hr><center>nginx</center>
  | </body>
  | </html>
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  | <!-- a padding to disable MSIE and Chrome friendly error page -->
  |  

Does that shine any light on the problem?

lusum commented 1 year ago

Same problem with apache, i see only a directory with the files, version 0.50.1

php 8.1

mitchray commented 1 year ago

Can you provide apache logs and browser console messages?

Simon is using a port in the URL, are you also?

mitchray commented 1 year ago

I think I've identified the problem...

Unfortunately so far I can only see two solutions and neither are good.

  1. Require everyone to build from source with their own URL hardcoded, instead of auto-detection which is broken with Vite.
  2. Revert Vite back to Snowpack and lose all the benefits of Vite.

I'll continue exploring solutions

mitchray commented 1 year ago

@SimonHova @lusum can you test with 0.50.2 please and report back if it works

https://github.com/mitchray/ample/releases/tag/0.50.2

lusum commented 1 year ago

Same problem with 0.50.2, no particular error. If i click on index.html, it appears the login page, but when i log into i have a Sorry not found message with nothing shown.

lusum commented 1 year ago

Partial logs

"GET /ampache-dev/ample/index.html HTTP/1.1" 200 1016 "-" "GET /ampache-dev/ample/assets/index.fbfb013f.css HTTP/1.1" 200 13441 "http://192.168.x.x/ampache-dev/ample/index.html" "GET /ampache-dev/ample/assets/index.fbfb013f.css HTTP/1.1" 200 13440 "http://192.168.x.x/ampache-dev/ample/index.html" "GET /ampache-dev/ample/assets/index.381f3380.js HTTP/1.1" 200 184195 "http://192.168.x.x/ampache-dev/ample/index.html" "GET /ampache-dev/server/json.server.php?action=ping HTTP/1.1" 200 321 "http://192.168.x.x/ampache-dev/ample/index.html" "GET /ampache-dev/server/json.server.php?action=ping&auth=e93457abe5e171b30cc459503ab143f7 HTTP/1.1" 200 896 "http://192.168.x.x/ampache-dev/ample/index.html" "GET /ampache-dev/ample/assets/refreshArtists.6ad790e5.js HTTP/1.1" 200 906 "http://192.168.x.x/ampache-dev/ample/index.html"

SimonHova commented 1 year ago

No good for me either.

nginx error log: 2022/12/11 21:18:22 [error] 583#583: *450018 directory index of "/opt/ampache/public/ample/" is forbidden, client: 10.18.1.152, server: 1xxxs.hxxxa.net, request: "GET /ample/ HTTP/1.1", host: "1xxxs.hxxxa.net:5006"

nginx access log: 10.18.1.152 - - [11/Dec/2022:21:20:36 -0500] "GET /ample/ HTTP/1.1" 403 180 "-" "Mozilla/5.0 (X11; CrOS x86_64 15183.59.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"

Nothing hits the Ampache debug logs on my side.

mitchray commented 1 year ago

Its most likely a server config issue then... check that index.html is a valid file to load

https://stackoverflow.com/a/36310143

Ample v0.50.0 switched from index.php to index.html so if it worked before v0.50.0 but is broken now, thats the leading theory.

SimonHova commented 1 year ago

The SO link worked for me! In addition to changing the rewrite rule to index.html, I had to change the index page to include the .html file as well.

index index.php index.html;

Thank you!