Reverse-Proxy (old version): Difference between revisions

From FlowerHouseWiki
m (Tropaion moved page Reverse-Proxy to Reverse-Proxy (old version))
 
(23 intermediate revisions by the same user not shown)
Line 5: Line 5:
|IP = 192.168.88.3
|IP = 192.168.88.3
|Privileged = No
|Privileged = No
|OS = Debian Buster
|OS = Debian Bullseye
|RAM = 1024MB
|RAM = 1024MB
|Cores = 1
|Cores = 1
|Files = [[reverse-proxy.conf]]
|Files = [[configuration.yml]]<br>[[users_database.yml]]<br>[[authelia_portal.conf]]<br>[[protected_endpoint.conf]]<br>[[UpdateAuthelia.sh]]
}}
}}
<p>The ReverseProxy is reachable under <syntaxhighlight lang="Bash" inline>192.168.88.3</syntaxhighlight> which is located in the ServerVLAN.</p>
<p>The ReverseProxy is reachable under <syntaxhighlight lang="Bash" inline>192.168.88.3</syntaxhighlight> which is located in the ServerVLAN.</p>
Line 17: Line 17:
=== Nginx Proxy Manager ===
=== Nginx Proxy Manager ===
<p>Download installation script and run it</p>
<p>Download installation script and run it</p>
<syntaxhighlight lang="console" line>
<syntaxhighlight lang="console">
cd ~
wget --no-cache -qO - https://raw.githubusercontent.com/ej52/proxmox/main/lxc/nginx-proxy-manager/setup.sh | sh
wget https://raw.githubusercontent.com/Tropaion/proxmox-scripts/main/lxc/nginx-proxy-manager/setup.sh
./setup.sh
</syntaxhighlight>
</syntaxhighlight>
<p>After installation, the webinterface should be reachable, standard login is</p>
<p>After installation, the webinterface should be reachable, standard login is</p>
Line 26: Line 24:
Email:    admin@example.com
Email:    admin@example.com
Password: changeme
Password: changeme
</syntaxhighlight>
=== Update ===
<p>Update NPM with following command</p>
<syntaxhighlight lang="console">
wget --no-cache -qO - https://raw.githubusercontent.com/ej52/proxmox/main/lxc/nginx-proxy-manager/setup.sh | sh
</syntaxhighlight>
</syntaxhighlight>


Line 51: Line 55:
</syntaxhighlight>
</syntaxhighlight>


<p>Open Redis CLI and set passphrase for redis server, which is needed in the authelia configuration file</p>
<p>Open Redis Config and set passphrase for redis server, which is needed in the authelia configuration file. Find <code># requirepass</code> in line 790 and change it <code>requirepass "my_redis_password"</code></p>
<syntaxhighlight lang="console" line>
<syntaxhighlight lang="console" line>
redis-cli
nano /etc/redis/redis.conf
CONFIG SET requirepass "yourpassword"
</syntaxhighlight>
 
<p>Restart redis to apply config</p>
<syntaxhighlight lang="console" line>
systemctl restart redis
</syntaxhighlight>
</syntaxhighlight>


<p>Test if passphrase is working correctly and exit CLI</p>
<p>Test if passphrase is working correctly and exit</p>
<syntaxhighlight lang="console" line>
<syntaxhighlight lang="console" line>
redis-cli
AUTH yourpassword
AUTH yourpassword
exit
exit
Line 64: Line 73:


=== Installation ===
=== Installation ===
<p>Download and untar latest Authelia archive:</p>
<p>Download and install package file:</p>
<syntaxhighlight lang="console" line>
cd ~
wget https://github.com/authelia/authelia/releases/download/v4.29.4/authelia-v4.29.4-linux-amd64.tar.gz
tar -zxvf authelia-v4.29.4-linux-amd64.tar.gz
rm authelia-v4.29.4-linux-amd64.tar.gz
</syntaxhighlight>
 
<p>Create authelia folder</p>
<syntaxhighlight lang="console">
mkdir /etc/authelia
</syntaxhighlight>
 
<p>Move files</p>
<syntaxhighlight lang="console" line>
<syntaxhighlight lang="console" line>
mv authelia-linux-amd64 /usr/bin/authelia
wget https://github.com/authelia/authelia/releases/download/v4.36.3/authelia_v4.36.3_amd64.deb
mv config.template.yml /etc/authelia/config.template.yml
apt install ./authelia_v4.36.3_amd64.deb
mv authelia.service /etc/systemd/system/
</syntaxhighlight>
 
<p>Set permissions</p>
<syntaxhighlight lang="console" line>
chmod 775 /usr/bin/authelia
chown root:root /usr/bin/authelia
</syntaxhighlight>
</syntaxhighlight>


==== configuration.yml ====
==== configuration.yml ====
<p>Create configuration file, modify and paste [[configuration.yml]]</p>
<p>Edit onfiguration file, modify and paste [[configuration.yml]]</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
nano /etc/authelia/configuration.yml
nano /etc/authelia/configuration.yml
Line 102: Line 91:


==== users_database.yml ====
==== users_database.yml ====
<p>Create users_database, modify and paste [[users_database]]</p>
<p>Create users_database, modify and paste [[users_database.yml]]</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
nano /etc/authelia/users_database.yml
nano /etc/authelia/users_database.yml
Line 123: Line 112:
</syntaxhighlight>
</syntaxhighlight>


<p>Enable authelia at boot:</p>
<p>Enable authelia at boot</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
systemctl enable authelia
systemctl enable authelia
</syntaxhighlight>
</syntaxhighlight>
=== Update ===
To update authelia, I made an bash script: [[UpdateAuthelia.sh]]


== Configure Nginx Proxy Manager ==
== Configure Nginx Proxy Manager ==
Line 134: Line 126:
* At the advanced tab add content of file [[authelia_portal.conf]]
* At the advanced tab add content of file [[authelia_portal.conf]]


<p>To enable the login portal for a host, go to the advanced tab and add the contenct of [[protected_endpoint]]</p>
<p>To enable the login portal for a host, go to the advanced tab and add the contenct of [[protected_endpoint.conf]]</p>
* Line 33 and 34 needs to be edited
* Line 3, 33 and 34 needs to be edited


== Sources ==
== Sources ==

Latest revision as of 20:47, 11 February 2023

Reverse-Proxy-LXC
Reverse proxy.png

Network


IP: 192.168.88.3
MAC: 56:59:71:B1:85:BC

System


OS: Debian Bullseye
Files: configuration.yml
users_database.yml
authelia_portal.conf
protected_endpoint.conf
UpdateAuthelia.sh
RAM: 1024MB
Cores: 1
Privileged: No

The ReverseProxy is reachable under 192.168.88.3 which is located in the ServerVLAN.

Every incoming packages from outside are forwarded to this IP.

The ReverseProxy also forces outside connections to use HTTPS/SSL and will provide a SSL-Certificate.

Basic Setup

Nginx Proxy Manager

Download installation script and run it

wget --no-cache -qO - https://raw.githubusercontent.com/ej52/proxmox/main/lxc/nginx-proxy-manager/setup.sh | sh

After installation, the webinterface should be reachable, standard login is

Email:    admin@example.com
Password: changeme

Update

Update NPM with following command

wget --no-cache -qO - https://raw.githubusercontent.com/ej52/proxmox/main/lxc/nginx-proxy-manager/setup.sh | sh

Authelia

For security reasons and convenience, the login portal Authelia will be installed.

Redis-Server

Install Redis with the following command:

apt install redis-server

After installing Redis, start redis service and enable it to start after system reboot with the following command:

systemctl start redis-server
systemctl enable redis-server

Verify the status of the redis server:

systemctl status redis-server

By default, Redis listening on the localhost on port 6379. You can check it with the following command:

ps -ef | grep redis

Open Redis Config and set passphrase for redis server, which is needed in the authelia configuration file. Find # requirepass in line 790 and change it requirepass "my_redis_password"

nano /etc/redis/redis.conf

Restart redis to apply config

systemctl restart redis

Test if passphrase is working correctly and exit

redis-cli
AUTH yourpassword
exit

Installation

Download and install package file:

wget https://github.com/authelia/authelia/releases/download/v4.36.3/authelia_v4.36.3_amd64.deb
apt install ./authelia_v4.36.3_amd64.deb

configuration.yml

Edit onfiguration file, modify and paste configuration.yml

nano /etc/authelia/configuration.yml

Restrict permissions for the configuration file

chmod 0600 /etc/authelia/configuration.yml

users_database.yml

Create users_database, modify and paste users_database.yml

nano /etc/authelia/users_database.yml

Password hash can be generated with following command

/usr/bin/authelia hash-password 'yourpassword' -i1 -k32 -l16 -m256 -p8

Restrict permissions for the users_database

chmod 0600 /etc/authelia/users_database.yml

Start authelia and check status

systemctl start authelia
systemctl status authelia

Enable authelia at boot

systemctl enable authelia

Update

To update authelia, I made an bash script: UpdateAuthelia.sh

Configure Nginx Proxy Manager

Create Proxy-Host for Authelia:

  • auth.flowerhouse.at -> Scheme: http, Forward IP: 192.168.88.3, Port: 9091
  • Chache Assests: On, Block Common Exploits: On
  • At the advanced tab add content of file authelia_portal.conf

To enable the login portal for a host, go to the advanced tab and add the contenct of protected_endpoint.conf

  • Line 3, 33 and 34 needs to be edited

Sources