Closed justinh998 closed 2 months ago
If you use SSL please set APP_URL=https://2fa.example.com and after please run thease comands in docker container to clear caches.
docker exec -it 2FAuth bash
after inside container change to 2fa app directory common is: cd /var/www/2fa/ and next run these commands to clear cache. sudo -u www-data php artisan config:clear sudo -u www-data php artisan config:cache sudo -u www-data php artisan route:clear sudo -u www-data php artisan view:cache sudo -u www-data php artisan optimize:clear
If you use SSL please set APP_URL=https://2fa.example.com and after please run thease comands in docker container to clear caches.
docker exec -it 2FAuth bash
after inside container change to 2fa app directory common is: cd /var/www/2fa/ and next run these commands to clear cache. sudo -u www-data php artisan config:clear sudo -u www-data php artisan config:cache sudo -u www-data php artisan route:clear sudo -u www-data php artisan view:cache sudo -u www-data php artisan optimize:clear
Thanks I will try it later, but I would still be interested to know why I should set the app url (where the external address of my server should be) to a non-existent address? I have also looked in the code, it does not happen especially when I enter this web address there.
location / {
proxy_pass http://backend_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
First need to run command: a2enmod ssl proxy proxy_http headers and add these settings inside virtualhost used for reverse proxy:
ProxyPreserveHost On
ProxyPass / http://backend_server/
ProxyPassReverse / http://backend_server/
RequestHeader set Host %{HTTP_HOST}s
RequestHeader set X-Real-IP %{REMOTE_ADDR}s
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
RequestHeader set X-Forwarded-Proto %{REQUEST_SCHEME}s
It is not advisable to use Cloudflare with SSL Offload because the data are unencrypted but can change these and try:
But i think laravel does support "cloudflare Flexible - SSL/TLS". Check this: https://community.fly.io/t/laravel-ssl-cloudfare/8618/2 https://stackoverflow.com/questions/42633428/using-cloudflare-flexible-ssl-option-causes-login-form-to-refresh-instead-of-sen
I recoomend to get a Let's Encrypt SSL certificate and put that on your site so that the communication between CloudFlare and your site is all SSL. https://letsencrypt.org/
I then tried using a reverse proxy (Cloudflared in my case(claudfared creates a claudfare tunnel through which the data is sent and cloudfare then takes care of the certificates, so I don't have to keep renewing them) ) and realised that I was getting a "mixed content" warning and my browser was refusing to load the page.
Hi,
From this point you should have set TRUSTED_PROXIES=*
. As cloudflare probably terminates TLS / SSL certificates, it tells 2FAuth to accept http from the proxy while https is expected via APP_URL=https://...
This is why your browser complained about mixed content.
Also, if you run v5.0.4 or higher, do not set ASSET_URL
, APP_URL
is enough.
Version
v5.2.0
Details & Steps to reproduce
Hello,
I am currently trying to get fauth2 to work somehow via HTTPS.
Firstly, I created a domain that points to the IP of my machine with 2fauth (in my case with Cloudflare). I then entered this domain in the Docker Compose configuration of 2fauth including HTTPS was entered.
I realised that certificates for the domain were apparently missing. However, I could not find a way to store these certificates in 2fauth. This of course meant that the website was not loaded by my browser because SSL certificates were missing. So I finally gave up this way and assumed that 2fauth probably does not support secure connections.
I then tried using a reverse proxy (Cloudflared in my case(claudfared creates a claudfare tunnel through which the data is sent and cloudfare then takes care of the certificates, so I don't have to keep renewing them) ) and realised that I was getting a "mixed content" warning and my browser was refusing to load the page.
I then started googling and came across this issue that describes my problem. There it is suggested to set TRUSTED_PROXIES=* and to enter ASSET_URL=https://otp.xxxx.ch (this solution seems to have worked for many users). I did this, but without success, as I already realised in step 1 that a secure connection is probably not supported. I didn't get any more "mixed content" warnings, but instead I got a lot of ERR_SSL_PROTOCOL_ERROR (as in step 1).
Error & Logs
Execution environment
I have deployed 2fauth via Docker Compose on Docker. Here is my Docker Compose configuration:
Does anyone else have an idea what I'm doing wrong here?