Deploy Authelia without Docker and protect it with Fail2Ban #178
Comments
Hello @n4kre, thank you very much for this contribution. |
Hello @n4kre , I opened a wiki today. I will most probably put this tutorial there. What do you think? |
Nice idea! |
I will script it with ansible at some point but I think I can publish it as is in the meantime with a big warning at the beginning. |
Thank you @n4kre , I copy-pasted your tuto in the wiki: https://github.com/clems4ever/authelia/wiki. |
I tried this setup and used the files of the wiki page but it didn't work for me. |
Hi, i followed this guide and worked like a charm! Now i have my authelia server with nginx reverse proxy with single sign on But now what if I want to protect my webapp? My nginx has two webapps, listening on two different ports: 8081 - authelia I want to make portainer logins redirect to the authelia front end and skip the portainer access page, how can this be achieved? Portainer for login just uses a rest api, I tested it using curl and it's working fine: My idea is to redirect everything from portainer to authelia login if the JWT authelia token is not found in session, and, on successfull authelia login, redirect to portainer calling this rest API Is this possible or there's an easier way to achieve this? EDIT: Solved... this guide also tells how to protect a private domain |
@blastbeng how did you bypass portainer login for authelia? |
Hi all,
Below is a little “how-to”, just in case…
This might help people who want to get Authelia running without Docker. It includes basic security hygiene.
This is definitely not an “issue”, but I didn't know where to share it…
Deploy Authelia with NPM and protect it with Fail2Ban
Assumptions:
The following commands are to be typed as
root
user.authelia
(service account) to be used by Authelia.Then, make sure to adjust this configuration file to fit your setup.
$EDITOR /etc/systemd/system/authelia.service
Then, type the following conent.
Note: Redis and MongoDB instances that are used by Authelia are assumed to be on the same server as the latter. Remove or adjust the line starting with
Requires=
, otherwise.systemctl daemon-reload systemctl start authelia systemctl status authelia systemctl enable authelia
$EDITOR /etc/fail2ban/filter.d/authelia.conf
Then, you can type the following filter, for instance. Make sure to adapt this filter with future releases of Authelia, in case logging messages eventually change.
Now, enable Authelia's Fail2Ban jail.
$EDITOR /etc/fail2ban/jail.local
You may append the following content, for instance, or customize it – refer to Fail2Ban manual.
Below are a sample configurations of Nginx, suitable with Authelia, under the following assumptions:
https://login.example.com
and its backend is running athttp://127.0.0.1:4221
– Authelia's frontend and backend are served from the same machine.private.example.com
is a domain meant to be protected by Authelia. In this example,https://private.example.com
is proxified tohttp://127.0.0.1:8000
– not necessarily served by the same machine than Authelia itself.First, let's configure the Nginx server serving Authelia.
Then, here is how to configure an Nginx server so that its resources are protected by Authelia.
Two variants are possible, depending on whether this server runs on the same machine as Authelia or not.
Below is the case of an external server. See inline comments to know how to deal with a server running on the same machine as Authelia.
Note: For better legibility, I include snippets of codes – Nginx allows this. Therefore
include filename;
refers to the content of the filefilename
located under Nginx configuration directory, i.e./etc/nginx
, by default. I give below the content of the files used in previous Nginx configurations.Content of
ssl_login.example.com_params
orssl_private.example.com_params
: adapt paths pointed byssl_certificate
,ssl_certificate_key
andssl_trusted_certificate
directives:Content of
default_headers
:Content of
proxy_params
:Content of
authelia_check-auth_block_external_api
:Content of
authelia_check-auth_block_internal_api
(slightly different from the previous file):Content of
authelia_sso_params
:The text was updated successfully, but these errors were encountered: