[GH-ISSUE #681] Force HTTPS URLs #485

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

Originally created by @alex-phillips on GitHub (Nov 13, 2017).
Original GitHub issue: https://github.com/koel/koel/issues/681

I'm running koel with nginx behind CloudFlare which handles HTTPS certs for my automatically, but it basically proxies the request back to my origin server over port 80. I think koel is seeing the requests coming in over HTTP and generating all URLs as HTTP instead of HTTPS which is causing issues such as not being able to log in.

Is there a way to force koel to generate all URLs as HTTPS?

Originally created by @alex-phillips on GitHub (Nov 13, 2017). Original GitHub issue: https://github.com/koel/koel/issues/681 I'm running koel with nginx behind CloudFlare which handles HTTPS certs for my automatically, but it basically proxies the request back to my origin server over port 80. I think koel is seeing the requests coming in over HTTP and generating all URLs as HTTP instead of HTTPS which is causing issues such as not being able to log in. Is there a way to force koel to generate all URLs as HTTPS?
kerem closed this issue 2026-02-26 02:33:21 +03:00
Author
Owner

@jleonardolemos commented on GitHub (Nov 13, 2017):

@alex-phillips I think the right way is to setup https over your koel server.
Or you can try put this lines on index.php, after autoload require.

$_SERVER['SERVER_PORT'] = "443";
$_SERVER['HTTPS'] = "on";

It works for mi in another project.

<!-- gh-comment-id:343983964 --> @jleonardolemos commented on GitHub (Nov 13, 2017): @alex-phillips I think the right way is to setup https over your koel server. Or you can try put this lines on index.php, after autoload require. $_SERVER['SERVER_PORT'] = "443"; $_SERVER['HTTPS'] = "on"; It works for mi in another project.
Author
Owner

@hmrodrigues commented on GitHub (Jan 12, 2018):

Hey,

So I also had this issue and fixed my adding $_SERVER['HTTPS'] = "on"; after autoload.

@phanan is it possible to add a entry into .env to force HTTPS? this way we don't need to change the php files

<!-- gh-comment-id:357201908 --> @hmrodrigues commented on GitHub (Jan 12, 2018): Hey, So I also had this issue and fixed my adding $_SERVER['HTTPS'] = "on"; after autoload. @phanan is it possible to add a entry into .env to force HTTPS? this way we don't need to change the php files
Author
Owner

@mikeziri commented on GitHub (Apr 12, 2018):

that should be an .env option for sure HTTPS=false by default along with
URL::forceScheme('https'); on AppServiceProvider::boot(). with the if (env(HTTPS) === 'true')

<!-- gh-comment-id:380775040 --> @mikeziri commented on GitHub (Apr 12, 2018): that should be an .env option for sure **HTTPS=false** by default along with **URL::forceScheme('https');** on AppServiceProvider::boot(). with the **if (env(HTTPS) === 'true')**
Author
Owner

@UmutAlihan commented on GitHub (Oct 7, 2020):

@alex-phillips I think the right way is to setup https over your koel server.
Or you can try put this lines on index.php, after autoload require.

$_SERVER['SERVER_PORT'] = "443";
$_SERVER['HTTPS'] = "on";

It works for mi in another project.

YOU ARE MY HERO!

Beacuse of your beautiful workaround, I will be able to sleep tonight 💯

<!-- gh-comment-id:705222266 --> @UmutAlihan commented on GitHub (Oct 7, 2020): > @alex-phillips I think the right way is to setup https over your koel server. > Or you can try put this lines on index.php, after autoload require. > > $_SERVER['SERVER_PORT'] = "443"; > $_SERVER['HTTPS'] = "on"; > > It works for mi in another project. YOU ARE MY HERO! Beacuse of your beautiful workaround, I will be able to sleep tonight 💯
Author
Owner

@hulet commented on GitHub (Jul 27, 2023):

This can now be done by setting FORCE_HTTPS=true in .env.

<!-- gh-comment-id:1652959827 --> @hulet commented on GitHub (Jul 27, 2023): This can now be done by setting `FORCE_HTTPS=true` in `.env`.
Author
Owner

@alexkutsan commented on GitHub (Jul 24, 2024):

Is there a way to support both HTTP/HTTPS?
Now I would like to use koel by HTTP in my internal tailscale network.
But when I expose it by domain name with Nginx - I would like to use https.
Right now - I can use it in the internal network by HTTPS.
But when I try to reach it by HTTPS - it fails to load because it loads many resources by HTTP, that is not allowed by the browser:
изображение

<!-- gh-comment-id:2247852120 --> @alexkutsan commented on GitHub (Jul 24, 2024): Is there a way to support both HTTP/HTTPS? Now I would like to use koel by HTTP in my internal tailscale network. But when I expose it by domain name with Nginx - I would like to use https. Right now - I can use it in the internal network by HTTPS. But when I try to reach it by HTTPS - it fails to load because it loads many resources by HTTP, that is not allowed by the browser: <img width="725" alt="изображение" src="https://github.com/user-attachments/assets/3b333264-5d90-46f5-aac2-d29aee8bc3a6">
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#485
No description provided.