Skip to content

Commit b00decc

Browse files
authored
Serve planetpython.org via haproxy instead of direct (#391)
* planet: planet.psf.io internal cert * planet: bind port 9000 for internal http * planet: open port 9000 to internal network * planet: register internal http service with consul * planet: serve from haproxy loadbalancer * planet: install a cert on the load balancer for planetpython.org also refresh our dummy cert since it is nearly 10 years old 💀
1 parent af6d994 commit b00decc

File tree

9 files changed

+466
-355
lines changed

9 files changed

+466
-355
lines changed

pillar/base/firewall/planet.sls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% include "networking.sls" %}
2+
3+
firewall:
4+
frontend-planet:
5+
port: 9000
6+
source: *psf_internal_network

pillar/base/haproxy.sls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ haproxy:
6060
extra:
6161
- http-request replace-header Host ^.*$ pythonsoftwarefoundation.applytojob.com
6262

63+
planet:
64+
domains:
65+
- planetpython.org
66+
- www.planetpython.org
67+
verify_host: planet.psf.io
68+
check: "HEAD / HTTP/1.1\\r\\nHost:\\ planet.psf.io"
69+
6370
pypy-web:
6471
domains:
6572
- www.pypy.org

pillar/base/tls.sls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ tls:
3838
roles:
3939
- moin
4040

41+
planet.psf.io:
42+
roles:
43+
- planet
44+
4145
postgresql.psf.io:
4246
roles:
4347
- postgresql

pillar/dev/secrets/tls/certs/loadbalancer.sls

Lines changed: 420 additions & 352 deletions
Large diffs are not rendered by default.

pillar/dev/top.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ base:
6666
- match: nodegroup
6767
- planet
6868
- firewall.http
69+
- firewall.planet
6970

7071
'salt-master':
7172
- match: nodegroup

pillar/prod/top.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ base:
100100
- match: nodegroup
101101
- planet
102102
- firewall.http
103+
- firewall.planet
103104

104105
'pypy-web':
105106
- match: nodegroup

salt/haproxy/config/haproxy.cfg.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ listen tls:
8787
bind :20007 ssl alpn h2,http/1.1 crt www.pycon.org.pem
8888
bind :20008 ssl alpn h2,http/1.1 crt jython.org.pem
8989
bind :20009 ssl alpn h2,http/1.1 crt pypy.org.pem
90-
bind 0.0.0.0:443 ssl alpn h2,http/1.1 crt star.python.org.pem crt star.pypa.io.pem crt star.pyfound.org.pem crt speed.pypy.org.pem crt www.pycon.org.pem crt jython.org.pem crt pypy.org.pem crt salt-public.psf.io.pem
91-
bind :::443 ssl alpn h2,http/1.1 crt star.python.org.pem crt star.pypa.io.pem crt star.pyfound.org.pem crt speed.pypy.org.pem crt www.pycon.org.pem crt jython.org.pem crt pypy.org.pem crt salt-public.psf.io.pem
92-
bind :20010 ssl alpn h2,http/1.1 crt star.python.org.pem crt star.pypa.io.pem crt star.pyfound.org.pem crt speed.pypy.org.pem crt www.pycon.org.pem crt jython.org.pem crt pypy.org.pem crt salt-public.psf.io.pem
90+
bind 0.0.0.0:443 ssl alpn h2,http/1.1 crt star.python.org.pem crt star.pypa.io.pem crt star.pyfound.org.pem crt speed.pypy.org.pem crt www.pycon.org.pem crt jython.org.pem crt pypy.org.pem crt salt-public.psf.io.pem crt planetpython.org
91+
bind :::443 ssl alpn h2,http/1.1 crt star.python.org.pem crt star.pypa.io.pem crt star.pyfound.org.pem crt speed.pypy.org.pem crt www.pycon.org.pem crt jython.org.pem crt pypy.org.pem crt salt-public.psf.io.pem crt planetpython.org
92+
bind :20010 ssl alpn h2,http/1.1 crt star.python.org.pem crt star.pypa.io.pem crt star.pyfound.org.pem crt speed.pypy.org.pem crt www.pycon.org.pem crt jython.org.pem crt pypy.org.pem crt salt-public.psf.io.pem crt planetpython.org
9393

9494
mode http
9595

salt/planet/config/nginx.planet.conf.jinja

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ server {
2525
root /srv/{{ site }}/;
2626
}
2727

28+
server {
29+
listen 9000 ssl;
30+
server_name {{ site }};
31+
error_log /var/log/nginx/{{ site }}.error.log;
32+
access_log /var/log/nginx/{{ site }}.access.log;
33+
ssl_certificate /etc/ssl/private/planet.psf.io.pem;
34+
ssl_certificate_key /etc/ssl/private/planet.psf.io.pem;
35+
36+
root /srv/{{ site }}/;
37+
}
38+
2839
{% for domain in info.get("subject_alternative_names", []) %}
2940
server {
3041
server_name {{ domain }};

salt/planet/init.sls

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ planet-user:
2020
- require:
2121
- file: /etc/nginx/sites.d/
2222

23+
/etc/consul.d/service-planet.json:
24+
file.managed:
25+
- source: salt://consul/etc/service.jinja
26+
- template: jinja
27+
- context:
28+
name: planet
29+
port: 9000
30+
- user: root
31+
- group: root
32+
- mode: "0644"
33+
- require:
34+
- pkg: consul-pkgs
35+
2336
lego_bootstrap:
2437
cmd.run:
2538
- name: /usr/local/bin/lego -a --email="[email protected]" {% if pillar["dc"] == "vagrant" %}--server=https://salt-master.vagrant.psf.io:14000/dir{% endif %} --domains="{{ grains['fqdn'] }}" {%- for domain in pillar['planet']['subject_alternative_names'] %} --domains {{ domain }}{%- endfor %} --http --path /etc/lego --key-type ec256 run

0 commit comments

Comments
 (0)