29th / personnel-v2

Personnel management system version 2 (legacy)
4 stars 7 forks source link

Redirect old forum URLs to old forums #497

Closed wilson29thid closed 3 years ago

wilson29thid commented 3 years ago

Requests to URLs like:

https://forums.29th.org/discussion/42272/open-executive-producer#latest

Should redirect to:

https://vanilla.29th.org/discussion/42272/open-executive-producer#latest

(Or whatever subdomain we end up using)

Here's a clue on how to do this.

I've manually modified /etc/nginx/conf.d/discourse.conf in the app container and got it working with this bit just before the closing }:

  location /discussion/ {
    return 301 https://vanilla.29th.org$request_uri;
  }

Now just need to get that added via the app.yml.

wilson29thid commented 3 years ago

I got this working by modifying containers/app.yml to add:

hooks: # this line already exists
  after_ssl:
    - replace:
        filename: "/etc/nginx/conf.d/discourse.conf"
        from: "location @discourse {"
        to: |
          location /discussion/ {
            return 301 https://$$ENV_VANILLA_HOSTNAME$request_uri;
          }

          location @discourse {
  after_code: # this line already exists

I also added a line above with the other environment variables:

env: # this line already exists
  VANILLA_HOSTNAME: forums.29th.org

We'll have to change it to vanilla.29th.org (or whatever we call it) when we switch/launch.

After modifying this, we just run:

./launcher rebuild app

Now to figure out how to version control that 🤔