ocf / puppet

Puppet config for OCF servers and lab machines
https://www.ocf.berkeley.edu/
31 stars 71 forks source link

feat: option for 301 instead of 302 redirect #1411

Closed oliver-ni closed 9 months ago

oliver-ni commented 9 months ago

defaults to 302 because dumb browsers cache 301 redirects forever, but this adds an option if 301 is desired and whoever puts it knows what they're doing

(mainly for SEO purposes, 301 is better than 302)

ocfjenkins[bot] commented 9 months ago

Errored hosts (0)

Changed hosts (2)

Unaffected hosts (60)


Changed hosts
diff for death.ocf.berkeley.edu ```diff ******************************************* File[/opt/share/vhost-web.jinja] => parameters => content => @@ -17,5 +17,5 @@ # 301 redirects are more correct, but get cached forever by dumb browsers. # Doesn't matter too much for vhosts. - RewriteRule ^(.*)$ {{vhost.redirect_dest}}$1 [L,R=302] + RewriteRule ^(.*)$ {{vhost.redirect_dest}}$1 [L,R={{vhost.redirect_type}}] {% elif vhost.is_apphost %} RequestHeader set X-Forwarded-Proto https ******************************************* File[/usr/local/bin/build-vhosts] => parameters => content => @@ -140,4 +140,10 @@ _ @property + def redirect_type(self): + if '301' in self.additional_rules: + return 301 + return 302 + + @property def websocket_locations(self): if self.bind_type == 'socket' and 'ws' in self.additional_rules: @@ -180,4 +186,6 @@ if ws_match: additional_rules.setdefault('ws', []).append(ws_match.group(1)) + elif flag == '301': + additional_rules['301'] = True _ # primary vhost @@ -241,5 +249,5 @@ bind_type='redirect', bind_dest=primary.canonical_url, - additional_rules={}, + additional_rules=additional_rules, )) _ ******************************************* ```
diff for vampires.ocf.berkeley.edu ```diff ******************************************* File[/usr/local/bin/build-vhosts] => parameters => content => @@ -140,4 +140,10 @@ _ @property + def redirect_type(self): + if '301' in self.additional_rules: + return 301 + return 302 + + @property def websocket_locations(self): if self.bind_type == 'socket' and 'ws' in self.additional_rules: @@ -180,4 +186,6 @@ if ws_match: additional_rules.setdefault('ws', []).append(ws_match.group(1)) + elif flag == '301': + additional_rules['301'] = True _ # primary vhost @@ -241,5 +249,5 @@ bind_type='redirect', bind_dest=primary.canonical_url, - additional_rules={}, + additional_rules=additional_rules, )) _ ******************************************* ```
Unaffected hosts ``` acid.ocf.berkeley.edu anthrax.ocf.berkeley.edu arsenic.ocf.berkeley.edu asteroid.ocf.berkeley.edu autocrat.ocf.berkeley.edu avalanche.ocf.berkeley.edu bedbugs.ocf.berkeley.edu bermudatriangle.ocf.berkeley.edu bigbang.ocf.berkeley.edu biohazard.ocf.berkeley.edu blight.ocf.berkeley.edu blizzard.ocf.berkeley.edu chaos.ocf.berkeley.edu corruption.ocf.berkeley.edu coup.ocf.berkeley.edu cyanide.ocf.berkeley.edu cyclone.ocf.berkeley.edu dataloss.ocf.berkeley.edu deadlock.ocf.berkeley.edu dementors.ocf.berkeley.edu democracy.ocf.berkeley.edu destruction.ocf.berkeley.edu drought.ocf.berkeley.edu fallingrocks.ocf.berkeley.edu famine.ocf.berkeley.edu firestorm.ocf.berkeley.edu firewhirl.ocf.berkeley.edu flood.ocf.berkeley.edu fraud.ocf.berkeley.edu gridlock.ocf.berkeley.edu hailstorm.ocf.berkeley.edu headcrash.ocf.berkeley.edu heatwave.ocf.berkeley.edu hurricane.ocf.berkeley.edu implosion.ocf.berkeley.edu invasion.ocf.berkeley.edu lethe.ocf.berkeley.edu lightning.ocf.berkeley.edu madcow.ocf.berkeley.edu maelstrom.ocf.berkeley.edu meteorstorm.ocf.berkeley.edu outbreak.ocf.berkeley.edu pestilence.ocf.berkeley.edu plague.ocf.berkeley.edu quarantine.ocf.berkeley.edu reaper.ocf.berkeley.edu riptide.ocf.berkeley.edu scurvy.ocf.berkeley.edu segfault.ocf.berkeley.edu sinkhole.ocf.berkeley.edu supernova.ocf.berkeley.edu surge.ocf.berkeley.edu thunder.ocf.berkeley.edu tornado.ocf.berkeley.edu tsunami.ocf.berkeley.edu venom.ocf.berkeley.edu volcano.ocf.berkeley.edu whiteout.ocf.berkeley.edu wildfire.ocf.berkeley.edu windshear.ocf.berkeley.edu ```

Jenkins