Skip to content

Commit 128db99

Browse files
committed
containers_web: switch to apache proxy
* replaces nginx container * gitea uses http/1.1 only, due to go-gitea/gitea#19265 * vaultwarden admin uses oidc sso
1 parent 8b87603 commit 128db99

File tree

18 files changed

+148
-210
lines changed

18 files changed

+148
-210
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RemoteIPHeader X-Forwarded-For
2+
RemoteIPTrustedProxy 10.88.0.0/24
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<VirtualHost *:443>
2+
ServerName gitea.chrisx.xyz
3+
SSLEngine on
4+
SSLCertificateFile /etc/ssl/chrisx.xyz/fullchain.pem
5+
SSLCertificateKeyFile /etc/ssl/chrisx.xyz/privkey.pem
6+
7+
Header always set Referrer-Policy "no-referrer"
8+
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
9+
Header always set X-Content-Type-Options "nosniff"
10+
Header always set X-Robots-Tag "none"
11+
Header always set X-XSS-Protection "1; mode=block"
12+
13+
AllowEncodedSlashes NoDecode
14+
15+
ProxyPass /robots.txt !
16+
ProxyPass / http://127.0.0.1:53000/
17+
ProxyPassReverse / http://127.0.0.1:53000/
18+
ProxyPreserveHost On
19+
ProxyRequests off
20+
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
21+
22+
ErrorLog /var/log/httpd/gitea_error_log
23+
CustomLog /var/log/httpd/gitea_access_log combined
24+
</VirtualHost>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<VirtualHost *:443>
2+
ServerName sso.chrisx.xyz
3+
SSLEngine on
4+
SSLCertificateFile /etc/ssl/chrisx.xyz/fullchain.pem
5+
SSLCertificateKeyFile /etc/ssl/chrisx.xyz/privkey.pem
6+
Protocols h2 http/1.1
7+
8+
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
9+
10+
AliasMatch "^/resources/.+/login/keycloak/img/favicon.ico$" /var/www/html/favicon.ico
11+
RedirectMatch 404 "^/$"
12+
13+
ProxyPassMatch "^/$" !
14+
ProxyPassMatch "^/resources/.+/login/keycloak/img/favicon.ico$" !
15+
ProxyPass / http://127.0.0.1:58080/
16+
ProxyPassReverse / http://127.0.0.1:58080/
17+
ProxyPreserveHost On
18+
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
19+
20+
ErrorLog /var/log/httpd/sso_error_log
21+
CustomLog /var/log/httpd/sso_access_log combined
22+
</VirtualHost>

roles/containers_web/files/nginx/conf.d/1-default.conf

Lines changed: 0 additions & 14 deletions
This file was deleted.

roles/containers_web/files/nginx/conf.d/gitea.conf

Lines changed: 0 additions & 25 deletions
This file was deleted.

roles/containers_web/files/nginx/conf.d/sso.conf

Lines changed: 0 additions & 32 deletions
This file was deleted.

roles/containers_web/files/nginx/conf.d/vaultwarden.conf

Lines changed: 0 additions & 35 deletions
This file was deleted.

roles/containers_web/files/nginx/nginx.conf

Lines changed: 0 additions & 47 deletions
This file was deleted.

roles/containers_web/files/nginx/www/robots.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

roles/containers_web/tasks/apache.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
- name: Copy favicon
2+
ansible.builtin.copy:
3+
src: favicon.ico
4+
dest: /var/www/html
5+
mode: 0644
6+
7+
- name: Generate new OIDC crypto password
8+
ansible.builtin.set_fact:
9+
oidc_crypto: "{{ lookup('password', '/dev/null length=64') }}"
10+
- name: Copy vaultwarden site config
11+
ansible.builtin.template:
12+
src: vaultwarden.conf.j2
13+
dest: /etc/httpd/conf.d/vaultwarden.conf
14+
mode: 0640
15+
- name: Copy Apache site config
16+
ansible.builtin.copy:
17+
src: httpd/conf.d
18+
dest: /etc/httpd
19+
mode: 0640
20+
21+
- name: Copy chrisx ssl certs
22+
ansible.builtin.import_role:
23+
name: sslcert
24+
tasks_from: chrisx.yml
25+
26+
- name: Configure SELinux httpd_can_network_connect
27+
ansible.posix.seboolean:
28+
name: httpd_can_network_connect
29+
persistent: true
30+
state: true
31+
32+
- name: Restart httpd
33+
ansible.builtin.systemd:
34+
name: httpd
35+
state: restarted

roles/containers_web/tasks/main.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@
88
mode: 0700
99
register: _containers_dir
1010

11-
- name: Configure Nginx
12-
ansible.builtin.import_tasks: nginx.yml
13-
- name: Copy helper scripts
14-
ansible.builtin.import_tasks: scripts.yml
15-
1611
- name: Set up Postgres DBs
1712
ansible.builtin.import_tasks: postgres_db.yml
1813
become_user: postgres
1914
delegate_to: postgres
2015

21-
- name: Create container network
22-
containers.podman.podman_network:
23-
name: ct
24-
state: present
25-
2616
- name: Launch containers
2717
ansible.builtin.import_role:
2818
name: containers
19+
20+
- name: Configure Apache sites
21+
ansible.builtin.import_tasks: apache.yml
22+
- name: Copy helper scripts
23+
ansible.builtin.import_tasks: scripts.yml

roles/containers_web/tasks/scripts.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
- name: Copy logrotate config
2-
ansible.builtin.template:
3-
src: logrotate.conf.j2
4-
dest: "{{ _containers_dir.path }}/log/logrotate.conf"
5-
mode: 0644
6-
- name: Set up logrotate cron job
7-
ansible.builtin.cron:
8-
name: container logrotate
9-
# yamllint disable-line rule:line-length
10-
job: "/usr/sbin/logrotate -s {{ _containers_dir.path }}/log/logrotate.state {{ _containers_dir.path }}/log/logrotate.conf"
11-
hour: 2
12-
minute: 0
13-
state: present
14-
151
- name: Copy backup script
162
ansible.builtin.template:
173
src: backup.sh

roles/containers_web/templates/logrotate.conf.j2

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<VirtualHost *:443>
2+
ServerName vaultwarden.chrisx.xyz
3+
SSLEngine on
4+
SSLCertificateFile /etc/ssl/chrisx.xyz/fullchain.pem
5+
SSLCertificateKeyFile /etc/ssl/chrisx.xyz/privkey.pem
6+
Protocols h2 http/1.1
7+
8+
Header unset Referrer-Policy
9+
Header unset X-XSS-Protection
10+
Header always set Referrer-Policy "no-referrer"
11+
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
12+
Header always set X-Robots-Tag "none"
13+
Header always set X-XSS-Protection "1 mode=block"
14+
15+
ProxyPass /admin/logout !
16+
ProxyPass /robots.txt !
17+
ProxyPass / http://127.0.0.1:58288/
18+
ProxyPassReverse / http://127.0.0.1:58288/
19+
ProxyPreserveHost On
20+
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
21+
22+
RewriteEngine on
23+
RewriteCond %{HTTP:Upgrade} =websocket [NC]
24+
RewriteRule /notifications/hub(.*) ws://127.0.0.1:53012/$1 [P,L]
25+
Redirect 302 /admin/logout /admin/openid-connect?logout=
26+
27+
ErrorLog /var/log/httpd/vaultwarden_error_log
28+
CustomLog /var/log/httpd/vaultwarden_access_log combined
29+
30+
OIDCClientID vaultwarden.chrisx.xyz
31+
OIDCClientSecret {{ vaultwarden_client_secret }}
32+
OIDCPassClaimsAs none
33+
OIDCProviderMetadataURL https://sso.chrisx.xyz/realms/chrisx/.well-known/openid-configuration
34+
OIDCRedirectURI https://vaultwarden.chrisx.xyz/admin/openid-connect
35+
OIDCScope openid
36+
OIDCSessionInactivityTimeout 3600
37+
OIDCStateMaxNumberOfCookies 2 true
38+
OIDCCryptoPassphrase {{ oidc_crypto }}
39+
40+
<Location "/admin/openid-connect">
41+
AuthType openid-connect
42+
Require valid-user
43+
</Location>
44+
45+
<Location "/admin">
46+
AuthType openid-connect
47+
Require claim roles:admin
48+
</Location>
49+
</VirtualHost>

0 commit comments

Comments
 (0)