Skip to content

Commit

Permalink
Merge pull request #41 from philtrep/fix-ssl-disabling
Browse files Browse the repository at this point in the history
Fixed nginx no SSL simple, fixes #40
  • Loading branch information
philtrep authored Oct 14, 2016
2 parents bdcb573 + 80d8ffd commit 8e1553d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ You can specify a `PROJECT_PATH` to change the directory in which `npm` will per
args:
MYSQL_DATABASE: default_database
MYSQL_USER: default_user
mysql_password: secret
MYSQL_PASSWORD: secret
```
<a name="NGINX-Reverse-Proxy-Port"></a>
#### Change the NGINX reverse proxy port
Expand Down
24 changes: 12 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ services:
build:
context: ./node
args:
NODE_VERSION: latest
PROJECT_PATH: /opt/app/
NODE_ENV: production
- NODE_VERSION=latest
- PROJECT_PATH=/opt/app/
- NODE_ENV=production
volumes:
- ../:/opt/app
extra_hosts:
Expand All @@ -20,9 +20,9 @@ services:
build:
context: ./mysql
args:
MYSQL_DATABASE: default_database
MYSQL_USER: default_user
mysql_password: secret
- MYSQL_DATABASE=default_database
- MYSQL_USER=default_user
- MYSQL_PASSWORD=secret
volumes_from:
- volumes
expose:
Expand All @@ -34,10 +34,10 @@ services:
build:
context: ./nginx
args:
WEB_REVERSE_PROXY_PORT: "8000"
WEB_SSL: "false"
SELF_SIGNED: "false"
NO_DEFAULT: "false"
- WEB_REVERSE_PROXY_PORT=8000
- WEB_SSL=false
- SELF_SIGNED=false
- NO_DEFAULT=false
volumes_from:
- volumes
ports:
Expand All @@ -59,8 +59,8 @@ services:
build:
context: ./workspace
args:
NODE_VERSION: latest
TZ: "UTC"
- NODE_VERSION=latest
- TZ=UTC
links:
- nginx
volumes:
Expand Down
4 changes: 2 additions & 2 deletions mysql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ RUN chown -R mysql:root /var/lib/mysql/

ARG MYSQL_DATABASE
ARG MYSQL_USER
ARG mysql_password
ARG MYSQL_PASSWORD

ENV MYSQL_DATABASE=$MYSQL_DATABASE
ENV MYSQL_USER=$MYSQL_USER
ENV MYSQL_PASSWORD=$mysql_password
ENV MYSQL_PASSWORD=$MYSQL_PASSWORD

RUN sed -i 's/MYSQL_DATABASE/'$MYSQL_DATABASE'/g' /etc/mysql/startup && \
sed -i 's/MYSQL_USER/'$MYSQL_USER'/g' /etc/mysql/startup && \
Expand Down
20 changes: 15 additions & 5 deletions nginx/scripts/build-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,35 @@ for template in /etc/nginx/templates/*.template; do
envsubst < $template > "/etc/nginx/sites-available/"$(basename $template)".conf"
done

if [ $NO_DEFAULT = "true" ]; then
if [[ "$NO_DEFAULT" = true ]]; then
rm /etc/nginx/sites-available/node.template.conf
rm /etc/nginx/sites-available/node-https.template.conf
else
if [[ "$WEB_SSL" = false ]]; then
rm /etc/nginx/sites-available/node-https.template.conf
fi
fi

if [ "$WEB_SSL" = "true" ] && [ "$NO_DEFAULT" = "false"]; then
if [ "$SELF_SIGNED" = "true" ]; then
if [[ "$WEB_SSL" = true && "$NO_DEFAULT" = false ]]; then
if [[ "$SELF_SIGNED" = true ]]; then
echo "---------------------------------------------------------"
echo "NGINX: Generating certificates"
echo "---------------------------------------------------------"
openssl req \
-new \
-newkey rsa:4096 \
-days 1095 \
-nodes \
-x509 \
-subj "/C=FK/ST=Fake/L=Fake/O=Fake/CN=0.0.0.0" \
-keyout /etc/ssl/privkey.pem \
-out /etc/ssl/cacert.pem
-keyout /etc/ssl/privkey1.pem \
-out /etc/ssl/cert1.pem
chown www-data:www-data /etc/ssl/cert1.pem
chown www-data:www-data /etc/ssl/privkey1.pem
else
echo "---------------------------------------------------------"
echo "NGINX: Using certificates in 'nodock/nginx/certs/'"
echo "---------------------------------------------------------"
if [ -e /var/certs/cert1.pem ]; then
cp /var/certs/cert1.pem /etc/ssl/cert1.pem
fi
Expand Down

0 comments on commit 8e1553d

Please sign in to comment.