Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use dev-nginx for setting up nginx in DEV #1867

Merged
merged 3 commits into from Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions support-frontend/nginx/Brewfile
@@ -0,0 +1,2 @@
tap "guardian/devtools"
brew "guardian/devtools/dev-nginx"
30 changes: 9 additions & 21 deletions support-frontend/nginx/README.md
@@ -1,33 +1,21 @@
# Support™ NGINX

## Setup Nginx for `Identity-Platform`

Support™ depends on Identity, so **you'll need to perform the**
[**Nginx setup for identity-platform**](https://github.com/guardian/identity-platform/blob/master/README.md#setup-nginx-for-local-development)
**first**, before you do anything else.

## Support-specific setup

#### Update your hosts file

Add the following local development domain to your hosts file in `/etc/hosts`:

- Install dependencies:
```bash
brew tap "guardian/devtools"
brew install "guardian/devtools/dev-nginx"
```
127.0.0.1 support.thegulocal.com
```

#### Run Support's Nginx setup script

Run the Support-specific [setup.sh](setup.sh) script from the root
of the `support-frontend` project:
Or from the `nginx` directory:
```bash
brew bundle
```
- Run [setup.sh](setup.sh) script from the root of the `support-frontend` project:

```
./nginx/setup.sh
```

The script doesn't start Nginx. To manually start it run `sudo nginx` or `sudo systemctl start nginx`
depending on your system.

#### NGINX error messages

nginx has some unhelpful error messages. Here are some translations:
Expand Down
20 changes: 15 additions & 5 deletions support-frontend/nginx/setup.sh
@@ -1,9 +1,19 @@
#!/bin/bash -x
#!/usr/bin/env bash

set -e

DOMAIN=support.thegulocal.com
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
NGINX_HOME=$(nginx -V 2>&1 | grep 'configure arguments:' | sed 's#.*conf-path=\([^ ]*\)/nginx\.conf.*#\1#g')
SITE_CONFIG=${DIR}/support.conf

DOMAINS=(
"support.thegulocal.com"
"support-ui.thegulocal.com"
)

echo "\n\nUsing NGINX_HOME=$NGINX_HOME"
for domain in ${DOMAINS[@]}; do
dev-nginx setup-cert $domain
done

sudo mkdir -p $NGINX_HOME/sites-enabled
sudo ln -fs $DIR/support.conf $NGINX_HOME/sites-enabled/support.conf
dev-nginx link-config ${SITE_CONFIG}
dev-nginx restart-nginx
8 changes: 4 additions & 4 deletions support-frontend/nginx/support.conf
Expand Up @@ -2,8 +2,8 @@ server {
listen 443 ssl;
server_name support.thegulocal.com;

ssl_certificate STAR_thegulocal_com_exp2020-01-09.crt; ## Supplied by https://github.com/guardian/identity-platform#setup-nginx-for-local-development
ssl_certificate_key STAR_thegulocal_com_exp2020-01-09.key; ## ditto
ssl_certificate support.thegulocal.com.crt;
ssl_certificate_key support.thegulocal.com.key;

ssl_prefer_server_ciphers on;

Expand Down Expand Up @@ -39,8 +39,8 @@ server {
listen 443 ssl;
server_name support-ui.thegulocal.com;

ssl_certificate STAR_thegulocal_com_exp2020-01-09.crt; ## Supplied by https://github.com/guardian/identity-platform#setup-nginx-for-local-development
ssl_certificate_key STAR_thegulocal_com_exp2020-01-09.key; ## ditto
ssl_certificate support-ui.thegulocal.com.crt;
ssl_certificate_key support-ui.thegulocal.com.key;

ssl_prefer_server_ciphers on;

Expand Down
12 changes: 0 additions & 12 deletions support-frontend/setup.sh
Expand Up @@ -133,16 +133,6 @@ install_js_deps() {
yarn install
}

fetch_dev_cert() {
aws s3 cp s3://identity-local-ssl/STAR_thegulocal_com_exp2020-01-09.crt ${NGINX_ROOT} --profile membership
aws s3 cp s3://identity-local-ssl/STAR_thegulocal_com_exp2020-01-09.key ${NGINX_ROOT} --profile membership
}

link_nginx_config() {
mkdir -p ${NGINX_ROOT}sites-enabled
ln -sf ${PWD}/nginx/support.conf ${NGINX_ROOT}sites-enabled/support.conf
}

report() {
if [[ ${#EXTRA_STEPS[@]} -gt 0 ]]; then
for i in "${!EXTRA_STEPS[@]}"; do
Expand All @@ -158,8 +148,6 @@ main () {
install_homebrew
install_nginx
install_awscli
fetch_dev_cert
link_nginx_config
install_jdk
install_sbt
install_yarn
Expand Down