-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Snipe-IT behind reverse proxy loads resources using HTTP instead of HTTPS #9179
Comments
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. |
I'm using the following with Cloudflare: # Listen on port 443
listen 443 ssl http2;
listen [::]:443 ssl http2;
# Listen on port 80
listen 80;
listen [::]:80;
# Redirect http requests to https
if ($http_x_forwarded_proto = "http") { return 301
https://$server_name$request_uri;
} Maybe you could try something similar or do a http redirect like this: server {
listen [::]:80;
server_name domain.com www.domain.com;
return 301 https://domain.com$request_uri;
} |
Generally, if your Also our docker container does support terminating SSL itself, might be worth giving that a shot if you have access to your certs (but if your SSL is being set up by Cloudflare, you wouldn't) |
I have configured my server to do this (but globally for all domains, that's why it is not shown here) but this does not work because Firefox did not tried to contact server, it blocked the request locally due to CSP.
My APP_URL has
I saw that but I would not like to use that because I need an external nginx to serve multiple sites using one IP. I have access to the certificates as I obtain them myself using Let's Encrypt so it would be possible in theory. What I can say further is that after continuing the installation process in debug mode, this did not happen again. After the installation process I disabled debug mode without having any CSP issues again, so only the installer seems to have this issue, so it might be a minor one. So this issue only happens if debug mode is disabled while Snipe-IT is not fully installed/configured as I currently see it. |
It's not only the installer having this issue. I've ran into this trying to deploy to a kubernetes cluster as well, routing through an ingress controller reverse proxy. The app is absolutely determined to fetch css/js assets through regular |
I will never understand why this is a use case that exists, but I try not to judge.
So, IIRC, that's a Symfony thing, not a Laravel (or even Snipe-IT thing). We specifically had to create some docs on proxies/reverse proxies because of the way Symfony handles requests. Not saying that makes it suck any less, it's just not something we have a lot of direct control over. If you're using the TRUSTED_PROXIES environmental variable, you should be okay. @uberbrady v6 of Laravel has some extra bullshit - I think our middleware/env handling already deals with this, but an extra set of eyes would be great: https://laravel.com/docs/6.x/requests#configuring-trusted-proxies |
Yes, I realize it's probably not an issue on your end, but the Edit: <?php
namespace App\Providers;
[...]
use Illuminate\Routing\UrlGenerator;
class AppServiceProvider extends ServiceProvider
{
public function boot(UrlGenerator $url)
{
if ( strpos(env('APP_URL'), 'https://') === 0 ) {
$url->forceScheme('https');
}
}
public function register()
{
[...]
}
} Not the prettiest of solutions, but modern browsers will block non-TLS calls from a website that is accessed through TLS anyway, so I don't know if it would hurt either. |
Just ran into this issue as well (I'm not using Kubernetes, just Traefik with docker-compose). I'm not entirely clear on what the purpose of the As a work-around, setting snipe-it/app/Providers/AppServiceProvider.php Lines 39 to 45 in b46e2b5
To fix this permanently, best practice would be for the HTML generated by Snipe-IT to not use absolute paths to subresources in cases where a relative URL would do. It sounds from the above comments like this is a problem with a dependency rather than with Snipe-IT itself. Is this something that needs to be reported upstream? I know pretty much nothing about Laravel or Symfony so forgive me if I'm totally off-base here, but a quick search suggests that Symfony does generate relative URLs when you use the asset component: https://symfony.com/doc/current/components/asset.html#asset-packages Snipe-IT doesn't seem to use that component though, instead generating URLs to subresources by calling
|
We had exactly the same symptoms at first and we were missing the the X-Forwarded-Proto header. We added a X-Forwarded-Proto header with a value of "https" before sending the snipe-it backend and that solved the problem in our use-case (all generated urls in raw source use the https protocol)
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
edit: i do not know about traefik but there is a mention of this header in their documentation so there must be a way to get this working |
I had the exact same problem with a proxy behind apache. Adding the following to the apache virtualhost fixed the issue: RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} |
In my case,
|
TL;DR: Thanks to @Ajedi32 for mentioning Elaboration: During setup of Snipe-It, some stylesheets (among which is Adding the environment variable |
What's the current consensus on this? The official docs say to use the trusted proxies and add a header in the reverse proxy server, but this is not doing anything for me, and APP_FORCE_TLS also doesn't seem to do a huge amount either |
@gahoo You're solution works:
But for the Snipe-IT folks, this seems to be a kluge that requires browser support. This does not solve the problem of Snipe-IT returning HTTP URL's when it should be returning HTTPS URL's. Like many other people here and elsewhere, I have followed the directions about |
My urls working fine wuth this setting and snipe-it login properly but my saved data not showing in https . fine in localhost and local ip can you help ? |
This is still an issue, and the official documentation produces a non-working result. I've tried adding APP_FORCE_TLS=true and it doesn't seem to do anything. If I have my APP_URL set to snipeit.domain.com (no port) it will fail the URL check, saying that my real URL is snipeit.domain.com:80. If I change it to APP_URL=snipeit.domain.com:80, Firefox will not load the page, with error SSL_ERROR_RX_RECORD_TOO_LONG. |
@erakura without knowing what version you're on, I'm not really sure how to help you. I think what you're looking for is https://snipe-it.readme.io/docs/configuration#optional-misc
|
@snipe Apologies for not including that information -- I'm on |
The |
FWIW in my case, add_header 'Content-Security-Policy' 'upgrade-insecure-requests'; worked- but it was only a select few resources that were still being passed over http: livewire.js, favicon.io, and selectlist. Devtools said the initiator of selectlist was all.js, but selectlist's get call is under the livewire tab in the debugger- so i think the root cause may be livewire.js. |
I also experienced this "something else" and traced it down to the TrustProxies middleware not being loaded. PR to fix this was merged almost instantly, so should be fixed in the next release :) |
Please confirm you have done the following before posting your bug report:
Describe the bug
Firefox does not load external resources like JavaScript or CSS files because of CSP because the original HTML page is loaded using HTTPS but Snipe-IT wants to load these resources using HTTP.
If I enable debug mode, Snipe-IT wants to load these using HTTPS. Because of that, I cannot append any stacktrace for now.
I use a Docker setup. Every run I tried after any configuration change included deleting all files and databases so no cache hopefully might have broken anything.
To Reproduce
Steps to reproduce the behavior (domain changed to
snipeit.example
):--port 127.0.0.1:12345:80
and especially configuring following environment variables:https://snipeit.example
and see error while debug mode is disabledExpected behavior
Screenshots
Error loading resources because of CSP (Domain is blurred):
No error loading resources while debug mode is enabled:
Server (please complete the following information):
Desktop (please complete the following information):
Error Messages
WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error
If a stacktrace is provided in the error, include that too.
Any errors that appear in your browser's error console.
Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo.
Include any additional information you can find in
storage/logs
and your webserver's logs.Include the output from
php -m
(this should display what modules you have enabled.)For error logs see browser screenshots
Additional context
Add any other context about the problem here.
Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.
The text was updated successfully, but these errors were encountered: