Skip to content

Commit 4bd670b

Browse files
committed
ocf_www: proxy apphost vhosts directly from nginx
Have nginx talk to apphost.ocf.berkeley.edu directly instead of going through Apache. Apache no longer needs SSL support so drop apache::mod::ssl and ocf_www::ssl.
1 parent ab81956 commit 4bd670b

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

modules/ocf_www/files/build-vhosts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,9 @@ def main():
417417

418418
web_vhosts = get_vhosts()
419419

420-
# Apache config (existing behavior)
420+
# Apache config (web vhosts only; apphost vhosts are proxied
421+
# directly by nginx and don't need Apache backend vhosts)
421422
apache_config = build_config(
422-
prod_app_vhosts,
423-
jinja_env.get_template('vhost-web.jinja'),
424-
dev_config=args.dev,
425-
)
426-
apache_config += '\n\n'
427-
apache_config += build_config(
428423
web_vhosts,
429424
jinja_env.get_template('vhost-web.jinja'),
430425
dev_config=args.dev,

modules/ocf_www/files/vhost-web-nginx.jinja

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ server {
2222
location / {
2323
{% if vhost.is_redirect %}
2424
return {{vhost.redirect_type}} {{vhost.redirect_dest}}$request_uri;
25+
{% elif vhost.is_apphost and vhost.disabled %}
26+
proxy_pass http://127.0.0.1:{{backend_port}};
27+
proxy_set_header Host unavailable.ocf.berkeley.edu;
28+
proxy_set_header X-Forwarded-For $remote_addr;
29+
proxy_set_header X-Forwarded-Proto $scheme;
30+
proxy_set_header X-Real-IP $remote_addr;
31+
{% elif vhost.is_apphost %}
32+
proxy_pass https://apphost.ocf.berkeley.edu;
33+
proxy_set_header Host $host;
34+
proxy_set_header X-Forwarded-For $remote_addr;
35+
proxy_set_header X-Forwarded-Proto $scheme;
36+
proxy_set_header X-Real-IP $remote_addr;
2537
{% else %}
2638
proxy_pass http://127.0.0.1:{{backend_port}};
2739
proxy_set_header Host $host;
@@ -40,7 +52,7 @@ server {
4052
proxy_set_header X-Forwarded-For $remote_addr;
4153
proxy_set_header X-Forwarded-Proto $scheme;
4254
proxy_set_header X-Real-IP $remote_addr;
43-
proxy_pass http://127.0.0.1:{{backend_port}};
55+
proxy_pass https://apphost.ocf.berkeley.edu;
4456
}
4557
{% endfor %}
4658

modules/ocf_www/files/vhost-web.jinja

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
# 301 redirects are more correct, but get cached forever by dumb browsers.
1010
# Doesn't matter too much for vhosts.
1111
RewriteRule ^(.*)$ {{vhost.redirect_dest}}$1 [L,R={{vhost.redirect_type}}]
12-
{% elif vhost.is_apphost %}
13-
RequestHeader set X-Forwarded-Proto https
14-
ProxyPreserveHost On
15-
SSLProxyEngine on
16-
# Proxy to apphost server
17-
ProxyPass / https://apphost.ocf.berkeley.edu/ upgrade=websocket
1812
{% elif vhost.disabled %}
1913
# Proxy to the local "unavailable" vhost, which serves up a friendly
2014
# "your website is rekt" page.

modules/ocf_www/manifests/init.pp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,8 @@
6969
backport_on => 'stretch';
7070
}
7171

72-
# Apache no longer serves SSL directly (nginx handles it), but mod_ssl is
73-
# still needed for SSLProxyEngine (outbound HTTPS to apphost).
74-
include apache::mod::ssl
75-
7672
include ocf_www::lets_encrypt
7773
include ocf_www::logging
78-
include ocf_www::ssl
7974

8075
# sites
8176
include ocf_www::site::ocfweb_redirects

0 commit comments

Comments
 (0)