Skip to content

Commit f7b002d

Browse files
authored
docs: update production nginx/certificate section & admin troubleshooting (#793)
1 parent 18e7dc6 commit f7b002d

5 files changed

Lines changed: 177 additions & 55 deletions

File tree

docs/admin/setup.rst

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,39 +121,48 @@ Additional Containers
121121
--restart unless-stopped \
122122
-p 80:80 -p 443:443 \
123123
-v /etc/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro \
124-
-v /etc/nginx/certs:/etc/nginx/certs:ro \
124+
-v /var/lib/rbg-cert:/var/lib/rbg-cert:ro \
125125
--net helios-network \
126126
nginx:latest
127127

128+
The nginx configuration files for each environment are in the repository root as: ``nginx.prod.conf`` and ``nginx.staging.conf``. There is no automation to copy these files to the server; you must manually copy the appropriate file to ``/etc/nginx/conf/nginx.conf`` on the server.
129+
130+
128131
- **SSL/TLS Certificates**:
129132

130-
.. warning::
131-
Do not forget to renew the certificates for both production and staging environments every 90 days!
133+
We are using SSL certificates provided by TUM, which are officially issued and valid for 1 year.
134+
135+
The certificate files are symlinked to auto-generated paths within ``/var/lib/rbg-cert``, and nginx is configured to use them directly. Because these are symlinks, ``nginx`` only needs to be restarted once a year—when the certificates are renewed—to pick up the updated files.
132136

133-
Certificates are generated manually using Certbot. For example::
137+
**Production**
134138

135-
sudo certbot certonly --standalone -d helios.aet.cit.tum.de
139+
.. code-block:: nginx
136140
137-
This creates certificate files under ``/etc/letsencrypt``. After generating the certificates, update the nginx configuration file at ``/etc/nginx/conf/nginx.conf`` to reference the new certificate and key files. Typical SSL snippet in ``nginx.conf``::
141+
ssl_certificate /var/lib/rbg-cert/live/host:f:asevm84.cit.tum.de.fullchain.pem;
142+
ssl_certificate_key /var/lib/rbg-cert/live/host:f:asevm84.cit.tum.de.privkey.pem;
138143
139-
server {
140-
listen 443 ssl;
141-
server_name helios.aet.cit.tum.de;
144+
**Staging**
142145

143-
ssl_certificate /etc/letsencrypt/live/helios.aet.cit.tum.de/fullchain.pem;
144-
ssl_certificate_key /etc/letsencrypt/live/helios.aet.cit.tum.de/privkey.pem;
146+
.. code-block:: nginx
145147
146-
# ... other configuration ...
147-
}
148+
ssl_certificate /var/lib/rbg-cert/live/host:f:asevm90.cit.tum.de.fullchain.pem;
149+
ssl_certificate_key /var/lib/rbg-cert/live/host:f:asevm90.cit.tum.de.privkey.pem;
148150
149-
Note that a reference version of the nginx configuration lives in the repository’s root as ``nginx.conf``—however, to see the live, up-to-date configuration in use, refer to the file at ``/etc/nginx/conf/nginx.conf``.
151+
After each deployment from GitHub, the deployment script runs
150152

151-
- **Important**: After each deployment (``docker-compose up``), the deployment script runs::
153+
.. code-block:: console
152154
153155
docker restart nginx
154156
155157
This ensures that nginx’s internal routing rules and certificate references are reloaded and point to the newly created container IPs.
156158

159+
.. warning::
160+
The renewal process of certificates is handled by the TUM ITG team. Every year, we need to restart the nginx container to apply the new certificates.
161+
162+
.. code-block:: console
163+
164+
docker restart nginx
165+
157166
158167
Helios Network
159168
---------------------

docs/admin/troubleshooting.rst

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ Troubleshooting Helios
88
:depth: 2
99

1010

11+
How to Re-Deploy Helios from GitHub Actions
12+
--------------------------------------------
13+
14+
To trigger a re-deployment of Helios without accessing the server manually, follow these steps using GitHub Actions:
15+
16+
- Open the Helios GitHub Repository
17+
- Go to the Actions Tab
18+
- Select the Deployment Workflow
19+
20+
- Choose one of the deployment workflows:
21+
22+
- Build and Deploy to Prod
23+
- Build and Deploy to Staging
24+
25+
- Locate the "Deploy" step within the job summary.
26+
- Rerun the "Deploy" job
27+
28+
- It will bring down the current services with ``docker compose down``.
29+
- A new ``.env`` file is generated dynamically using GitHub Environment secrets and variables (e.g., ``POSTGRES_PASSWORD``, ``NATS_URL``, etc.).
30+
- The services are brought back up using ``docker compose up -d``.
31+
- Finally, ``docker restart nginx`` is executed to reload routing and pick up any changes (e.g., environment updates or renewed TLS certificates).
32+
33+
1134
Updating SSL/TLS Certificates
1235
-------------------------------
1336

@@ -22,52 +45,21 @@ Updating SSL/TLS Certificates
2245
--restart unless-stopped \
2346
-p 80:80 -p 443:443 \
2447
-v /etc/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro \
25-
-v /etc/nginx/certs:/etc/nginx/certs:ro \
48+
-v /var/lib/rbg-cert:/var/lib/rbg-cert:ro \
2649
--net helios-network \
2750
nginx:latest
2851
2952
Once Nginx is running on the ``helios-network``, it will proxy traffic to the Helios services defined in Docker Compose.
3053

31-
When your Let’s Encrypt certificates approach expiration (every 90 days), follow these steps to renew and apply them.
32-
33-
1. **Renew Certificates**
34-
35-
Use Certbot in standalone mode to obtain or renew certificates for your Helios domain. Replace <your-domain> with your actual hostname (e.g., `helios.aet.cit.tum.de`):
36-
37-
.. code-block:: console
54+
We are using SSL/TLS certificates are provided by the TUM IT department and are valid for 1 year. These certificates are automatically renewed by ITG and exposed via symlinks under ``/var/lib/rbg-cert/live/``. Nginx is configured to use these paths directly in both staging and production environments. For more details and the relevant ``nginx.conf`` certificate paths, refer to the `Production Setup Guide -> Additional Containers -> nginx <setup.html#additional-containers>`_.
3855

39-
sudo certbot certonly --standalone -d <your-domain>
56+
.. warning::
4057

58+
The only required action is to **restart** the ``nginx`` container **once a year** when the certificates are renewed:
4159

42-
This will generate or renew the certificate files under:
43-
`/etc/letsencrypt/live/<your-domain>/fullchain.pem`
44-
`/etc/letsencrypt/live/<your-domain>/privkey.pem`
45-
46-
2. **Verify Nginx Configuration**
47-
48-
Ensure your Nginx configuration references the correct certificate paths. Open the live Nginx config (not the repository copy) at `/etc/nginx/conf/nginx.conf` and confirm lines similar to:
49-
50-
.. code-block:: nginx
51-
52-
server {
53-
listen 443 ssl;
54-
server_name <your-domain>;
55-
56-
ssl_certificate /etc/letsencrypt/live/<your-domain>/fullchain.pem;
57-
ssl_certificate_key /etc/letsencrypt/live/<your-domain>/privkey.pem;
58-
59-
# …other configuration…
60-
}
61-
62-
3. **Reload or Restart Nginx Container**
63-
64-
After certificates are in place and the config is correct, reload the Nginx container so it picks up the new files:
65-
66-
.. code-block:: console
67-
68-
docker restart nginx
60+
.. code-block:: console
6961
70-
This command restarts the Nginx container, applying the new SSL/TLS certificates.
62+
docker restart nginx
7163
7264
NATS Webhook Data Cleanup
7365
-------------------------------

docs/contributor/setup.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Setup Guide
33
====================
44

55
This guide focuses on setting up the Helios application on your local machine. The following sections will walk you through the necessary steps to install the required dependencies and run the application.
6-
The production setup is covered in the `Production Setup Guide <production_setup.html>`_.
6+
The production setup is covered in the `Production Setup Guide <../admin/setup.html>`_.
77

88

99
Prerequisites

nginx.conf renamed to nginx.prod.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ http {
2929
listen 443 ssl;
3030
server_name helios.aet.cit.tum.de;
3131

32-
ssl_certificate $SSL_CERT_PATH;
33-
ssl_certificate_key $SSL_KEY_PATH;
32+
ssl_certificate /var/lib/rbg-cert/live/host:f:asevm84.cit.tum.de.fullchain.pem;
33+
ssl_certificate_key /var/lib/rbg-cert/live/host:f:asevm84.cit.tum.de.privkey.pem;
3434

3535

3636
location / {

nginx.staging.conf

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Main configuration directives
2+
user nginx;
3+
worker_processes auto;
4+
error_log /var/log/nginx/error.log warn;
5+
pid /var/run/nginx.pid;
6+
7+
# Events block
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
# HTTP block
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
17+
# Docker's internal DNS resolver
18+
# When the compose is restarted, the IP addresses of the services might change
19+
# This is required for resolving the service names to their IP addresses
20+
resolver 127.0.0.11 ipv6=off;
21+
22+
# SSL Settings
23+
ssl_protocols TLSv1.2 TLSv1.3;
24+
ssl_ciphers HIGH:!aNULL:!MD5;
25+
ssl_prefer_server_ciphers on;
26+
27+
# First server block for HTTPS
28+
server {
29+
listen 443 ssl;
30+
server_name helios-staging.aet.cit.tum.de;
31+
32+
ssl_certificate /var/lib/rbg-cert/live/host:f:asevm90.cit.tum.de.fullchain.pem;
33+
ssl_certificate_key /var/lib/rbg-cert/live/host:f:asevm90.cit.tum.de.privkey.pem;
34+
35+
36+
location / {
37+
# Forward to webapp on port 80
38+
proxy_pass http://client:80;
39+
proxy_http_version 1.1;
40+
proxy_set_header Upgrade $http_upgrade;
41+
proxy_set_header Connection 'upgrade';
42+
proxy_set_header Host $host;
43+
proxy_cache_bypass $http_upgrade;
44+
}
45+
46+
# Proxy API requests
47+
location /api {
48+
proxy_pass http://application-server:8080; # Forward to application server
49+
proxy_http_version 1.1;
50+
proxy_set_header Upgrade $http_upgrade;
51+
proxy_set_header Connection 'upgrade';
52+
proxy_set_header Host $host;
53+
proxy_cache_bypass $http_upgrade;
54+
}
55+
56+
# Proxy Keycloak requests
57+
location ~* ^/(realms|resources|robots\.txt) {
58+
proxy_pass http://keycloak:8081;
59+
proxy_http_version 1.1;
60+
proxy_set_header Host $host;
61+
proxy_set_header X-Real-IP $remote_addr;
62+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
63+
proxy_set_header X-Forwarded-Proto https;
64+
proxy_set_header X-Forwarded-Port 443;
65+
proxy_cache_bypass $http_upgrade;
66+
}
67+
68+
# Keycloak admin console
69+
location /admin {
70+
proxy_pass http://keycloak:8081/admin;
71+
proxy_http_version 1.1;
72+
proxy_set_header Host $host;
73+
proxy_set_header X-Real-IP $remote_addr;
74+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
75+
proxy_set_header X-Forwarded-Proto https;
76+
proxy_set_header X-Forwarded-Port 443;
77+
proxy_cache_bypass $http_upgrade;
78+
}
79+
80+
location /github {
81+
# Only allow POST requests
82+
limit_except POST {
83+
deny all;
84+
}
85+
86+
# Validate required GitHub headers
87+
set $valid_headers 1;
88+
89+
if ($http_x_github_event = "") {
90+
set $valid_headers 0;
91+
}
92+
if ($http_x_github_delivery = "") {
93+
set $valid_headers 0;
94+
}
95+
if ($http_x_hub_signature_256 = "") {
96+
set $valid_headers 0;
97+
}
98+
99+
# Deny access if headers are invalid
100+
if ($valid_headers = 0) {
101+
return 403;
102+
}
103+
104+
# Forward to the webhook listener service
105+
proxy_pass http://webhook-listener:4200; # Forward to webhook listener on port 4200
106+
proxy_http_version 1.1;
107+
proxy_set_header Upgrade $http_upgrade;
108+
proxy_set_header Connection 'upgrade';
109+
proxy_set_header Host $host;
110+
proxy_cache_bypass $http_upgrade;
111+
}
112+
}
113+
114+
# Second server block for HTTP to HTTPS redirection
115+
server {
116+
listen 80;
117+
server_name helios-staging.aet.cit.tum.de;
118+
119+
return 301 https://$host$request_uri;
120+
}
121+
}

0 commit comments

Comments
 (0)