[GH-ISSUE #711] 404 /api/me #503

Closed
opened 2026-02-26 02:33:23 +03:00 by kerem · 3 comments
Owner

Originally created by @Tchoupinax on GitHub (Jan 13, 2018).
Original GitHub issue: https://github.com/koel/koel/issues/711

Hello,

I can log in on Koel because the request return 404.

  • The log page downloaded well with all ressources.
  • php artisan koel:init works and yarn production too
  • I first tried to launch php artisan servebut request were with the address http://localhost:8000although i changed APP_URL in .env

Error is :

Request URL:https://music.domaine.com/api/me
Request Method:POST
Status Code:404 Not Found

It feels working at http://demo.koel.phanan.net/

My NGINX configuration is :

server {
    listen 80;
    server_name music.domaine.com;
    return 301 https://$server_name$request_uri;
}

server {
    ssl on;
    ssl_certificate /var/www/ssl/music.domaine.com.crt;
    ssl_certificate_key /var/www/ssl/music.domaine.com.key;
    auth_basic "Restricted";

    root /home/[...]/Documents/koel;
    index index.php index.html index.htm;

    listen 443 ssl;
    server_name music.domaine.com;

    access_log /var/log/nginx/default-access_log;
    error_log /var/log/nginx/default-error_log;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Any idea ?
Thank you

Regards,

Originally created by @Tchoupinax on GitHub (Jan 13, 2018). Original GitHub issue: https://github.com/koel/koel/issues/711 Hello, I can log in on Koel because the request return 404. - [x] The log page downloaded well with all ressources. - [x] php artisan koel:init works and yarn production too - [x] I first tried to launch `php artisan serve`but request were with the address `http://localhost:8000`although i changed APP_URL in `.env` Error is : ``` Request URL:https://music.domaine.com/api/me Request Method:POST Status Code:404 Not Found ``` It feels working at `http://demo.koel.phanan.net/` My NGINX configuration is : ``` server { listen 80; server_name music.domaine.com; return 301 https://$server_name$request_uri; } server { ssl on; ssl_certificate /var/www/ssl/music.domaine.com.crt; ssl_certificate_key /var/www/ssl/music.domaine.com.key; auth_basic "Restricted"; root /home/[...]/Documents/koel; index index.php index.html index.htm; listen 443 ssl; server_name music.domaine.com; access_log /var/log/nginx/default-access_log; error_log /var/log/nginx/default-error_log; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~ /\.ht { deny all; } } ``` Any idea ? Thank you Regards,
kerem closed this issue 2026-02-26 02:33:23 +03:00
Author
Owner

@Tchoupinax commented on GitHub (Jan 13, 2018):

Hello,

Continue to testing... Local desktop this time.
Installing apache2 (I have nginx on my server). Try with php artisan serve, it works well ! But when i tried with virtualhost, same thing : welcome page worls well but can log in because of /api/me is not found.

Error:
Request URL:http://127.0.0.1/api/me Request Method:POST Status Code:404 Not Found

What i do not understand and that route are / and /api/me, / is ok but not /api/me. What is the problem ?

Regards,
(I can use it yet, but Koel seems very good ! Good job :) )

<!-- gh-comment-id:357465274 --> @Tchoupinax commented on GitHub (Jan 13, 2018): Hello, Continue to testing... Local desktop this time. Installing apache2 (I have nginx on my server). Try with `php artisan serve`, it works well ! But when i tried with virtualhost, same thing : welcome page worls well but can log in because of /api/me is not found. Error: `Request URL:http://127.0.0.1/api/me Request Method:POST Status Code:404 Not Found` What i do not understand and that route are `/` and `/api/me`, `/` is ok but not `/api/me`. What is the problem ? Regards, (I can use it yet, but Koel seems very good ! Good job :) )
Author
Owner

@gamerlv commented on GitHub (Jan 15, 2018):

To use Koel with nginx you need to be sure to have a rewrite in place to send all traffic to index.php.
The sample config you have provided is missing this rewrite.

You can find a recommended base nginx config in the repo: github.com/phanan/koel@566145678a/nginx.conf.example

Small nginx tip, if you have ssl in a listen line you don't need the ssl on directive.

<!-- gh-comment-id:357556654 --> @gamerlv commented on GitHub (Jan 15, 2018): To use Koel with nginx you need to be sure to have a rewrite in place to send all traffic to index.php. The sample config you have provided is missing [this rewrite](https://github.com/phanan/koel/blob/566145678a2a6f8a55785395454b0e2527fb0ebb/nginx.conf.example#L31). You can find a recommended base nginx config in the repo: https://github.com/phanan/koel/blob/566145678a2a6f8a55785395454b0e2527fb0ebb/nginx.conf.example Small nginx tip, if you have `ssl` in a `listen` line you don't need the `ssl on` directive.
Author
Owner

@cf512 commented on GitHub (Jun 20, 2018):

gamerlv is right

I replaced:

 location / {
        try_files $uri $uri/ =404;
    }

with:

  location / {
    try_files   $uri $uri/ /index.php?$args;
  }

in /etc/nginx/sites-enabled/default and it fixed the same issue for me.

<!-- gh-comment-id:398754356 --> @cf512 commented on GitHub (Jun 20, 2018): gamerlv is right I replaced: ``` location / { try_files $uri $uri/ =404; } ``` with: ``` location / { try_files $uri $uri/ /index.php?$args; } ``` in /etc/nginx/sites-enabled/default and it fixed the same issue for me.
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/koel-koel#503
No description provided.