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