Coder Social home page Coder Social logo

enes-usta / pages-redirects Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloud-gov/pages-redirects

0.0 0.0 0.0 953 KB

Redirects traffic from previous pages.18f.gov sites to their new URLs.

License: Other

JavaScript 42.11% Shell 2.48% Nunjucks 55.41%

pages-redirects's Introduction

pages-redirects

CircleCI

This app redirects traffic from previous pages.18f.gov sites to their new URLs, which are usually a subdomain of 18f.gov (eg pages.18f.gov/boop โ†’ boop.18f.gov).

This app also contains a number of non-pages.18f.gov-related redirects that were previously handled by federalist-redirects. These redirect rules can be found in templates/_federalist-redirects.njk.

Adding a new redirect

pages.18f.gov redirects

To add a new redirect from a retired pages.18f.gov to its new 18f.gov-subdomain home, you will need to edit pages.yml. Please open a Pull Request with your modifications.

If you need to add a simple redirect of pages.18f.gov/site-name to site-name.18f.gov, simply add a new line to the pages.yml that looks like:

- site-name

If you need to change the name of the old page to something new, like pages.18f.gov/old-name to new-name.18f.gov, add lines of the following form to pages.yml:

- from: old-name
  to: new-name

If you need to redirect to a different domain from 18f.gov, like pages.18f.gov/old-name to new-name.new-domain.gov, add lines of the following form to pages.yml:

- from: old-name
  to: new-name
  toDomain: new-domain.gov

Additionally you can redirect to a custom path on that domain, like pages.18f.gov/old-name to new-name.new-domain.gov/custom-path, add lines of the following form to pages.yml:

- from: old-name
  to: new-name
  toDomain: new-domain.gov
  toPath: custom-path

Domain redirects

To create a redirect for yourOrigDomain.gov to yourNewDomain.gov, perform the following steps:

  1. Add a route for yourOrigDomain.gov in manifest-prod.yml.njk
route: yourOrigDomain.gov
  1. Add a redirect configuration in _federalist-redirects.njk:
server {
  listen {{ PORT }};
  set $target_domain yourNewDomain.gov;
  server_name yourOrigDomain.gov;
  return 301 https://$target_domain;
}
  1. Add yourdOrigDomain.gov as an external link to docker-compose.yml
app:yourOrigDomain.gov
  1. Test this app as described below in the Testing section
  2. Create a pull request in the the dns repository to follow the cloud.gov instructions to create the required DNS entries for yourOrigDomain.gov and ask @federalist-admins and @tts-tech-portfolio for a review.
  3. Ask an administrator to create an external-domain for yourOrigDomain.gov.
cf create-service external-domain domain-with-cdn yourOrigDomain.gov -c '{"domains": "yourOrigDomain.gov"}'

Once your changes are merged into main by an administrator, the pages-redirects app will be redeployed by CircleCI and your redirects should start working within a few minutes.

Developing

This is a NodeJS-based project that uses yarn for managing node dependencies. After making sure you have it installed, run yarn to install dependencies.

The NodeJS code (called from build.js) reads an array of sites to redirect from the pages.yml file and inserts new NGINX rewrite rules into the nginx.conf.njk template in templates/. The resulting nginx.conf files (one for testing in Docker and one for the production site) are written to the out/ directory. The build script also produces a CloudFoundry manifest file at out/manifest-prod.yml for deploying this app to cloud.gov.

Testing

To run unit tests, run yarn test.

Integration Tests

Local Docker

You can run integration tests locally against a Docker container. First make sure you have Docker and Docker Compose installed, and maybe give the 18F Docker guide a read.

Then build and run tests in the docker-compose network:

yarn build-docker && yarn test-docker

Real server

To run integration tests against a real server:

TARGET_HOST=<FULL_URL_TOSERVER> yarn test-integration

For example:

TARGET_HOST=https://pages-redirects.app.cloud.gov yarn test-integration

Deploying

This is deployed in GovCloud cloud.gov:

  • org: gsa-18f-federalist
  • space: redirects

Automated Deployments

This app is automatically deployed by CircleCI when commits are pushed to the main branch (such as from a merged Pull Request). Deployments are done with the cf-autopilot plugin so that there will be no downtime.

See circle.yml and deploy-ci.sh for details.

Manual Deployments

To manually deploy (this should not be necessary):

yarn build
cf push -f out/manifest-prod.yml`

pages-redirects's People

Contributors

amirbey avatar wslack avatar jseppi avatar eddietejeda avatar davemcorwin avatar zachmargolis avatar afeld avatar jeremyzilar avatar dependabot[bot] avatar saracope avatar svenaas avatar wongperson avatar ccostino avatar ryanhofdotgov avatar jmhooper avatar shawnbot avatar stvnrlly avatar knuamah1 avatar mgwalker avatar brandocalrissian avatar apburnes avatar atrain440 avatar bradnunnally avatar thisisdano avatar emileighoutlaw avatar gbinal avatar gboone avatar hbillings avatar jjediny avatar martyspence avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.