Skip to content

Commit bc9eeca

Browse files
authored
Merge pull request #10 from Niek/https-support
Add support for HTTPS upstream, make sure to pass the upstream Host header
2 parents 882137b + 9cbf995 commit bc9eeca

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

default.conf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,23 @@ server {
1111
resolver $RESOLVERS valid=10s ipv6=off;
1212
set $upstream $UPSTREAM_HTTP_ADDRESS;
1313

14+
# Use the current host as the upstream host by default
15+
set $upstream_host $http_host;
16+
17+
# Check if our upstream address is HTTPS
18+
if ($upstream ~* ^https://([^:/]+)) {
19+
# Add these SSL configuration settings
20+
proxy_ssl_server_name on;
21+
proxy_ssl_protocols TLSv1.2 TLSv1.3;
22+
proxy_ssl_verify off;
23+
24+
# We also want to use the upstream host so SNI can be used - extract it from the upstream address
25+
set $upstream_host $1;
26+
}
27+
1428
location / {
1529
proxy_pass $upstream;
16-
proxy_set_header Host $http_host;
30+
proxy_set_header Host $upstream_host;
1731
proxy_set_header X-Real-IP $remote_addr;
1832
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1933
proxy_set_header X-Forwarded-Host $http_host;

0 commit comments

Comments
 (0)