From edadfd5c68450e6b8337b63d996fc29683509111 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Mon, 4 Jun 2018 15:34:40 -0700 Subject: [PATCH] more changes to get dockerization working --- docker-compose-development.yml | 2 +- docker-compose.yml | 4 +- ecosystem.json | 2 +- nginx/Dockerfile | 4 +- nginx/alpha.editor.p5js.org.conf | 61 ++++++++++++++++ nginx/nginx-aws.conf | 122 +++++++++++++++++++++++++++++++ nginx/nginx.conf | 61 ---------------- 7 files changed, 191 insertions(+), 65 deletions(-) create mode 100644 nginx/alpha.editor.p5js.org.conf create mode 100644 nginx/nginx-aws.conf diff --git a/docker-compose-development.yml b/docker-compose-development.yml index 9b97dd33..33d98f76 100644 --- a/docker-compose-development.yml +++ b/docker-compose-development.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3' services: mongo: image: mongo:3.4.7 diff --git a/docker-compose.yml b/docker-compose.yml index c324527d..a5d58f68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ -version: '2' +version: '3' services: mongo: image: mongo:3.4.7 + expose: + - "27017" nginx: build: ./nginx server: diff --git a/ecosystem.json b/ecosystem.json index 5f56d91f..edcd6311 100644 --- a/ecosystem.json +++ b/ecosystem.json @@ -4,6 +4,6 @@ "env": { "NODE_ENV": "production" }, - "instances" : 2, + "instances" : "max", "exec_mode" : "cluster" } \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 4c45e83b..9372b789 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,3 +1,5 @@ FROM nginx:1.13.12 -COPY nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +COPY nginx.conf /etc/nginx/nginx.conf +RUN mkdir /etc/nginx/sites-enabled +COPY alpha.editor.p5js.org.conf /etc/nginx/sites-enabled \ No newline at end of file diff --git a/nginx/alpha.editor.p5js.org.conf b/nginx/alpha.editor.p5js.org.conf new file mode 100644 index 00000000..ec704743 --- /dev/null +++ b/nginx/alpha.editor.p5js.org.conf @@ -0,0 +1,61 @@ + # HTTP - redirect all requests to HTTPS: + server { + listen 80; + server_name alpha.editor.p5js.org; + location / { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + location ~* \/login(\/)* { + return 301 https://$host$request_uri; + } + location ~* \/signup(\/)* { + return 301 https://$host$request_uri; + } + location ~* \/reset-password(\/)* { + return 301 https://$host$request_uri; + } + location ~* "\/[a-zA-Z0-9._-]{1,20}\/account(\/)*" { + return 301 https://$host$request_uri; + } + +} + +server { + listen 443; + ssl on; + ssl_certificate /etc/letsencrypt/live/alpha.editor.p5js.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/alpha.editor.p5js.org/privkey.pem; + server_name alpha.editor.p5js.org; + location / { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } +} + +server { + listen 80; + server_name editor.p5js.org; + location ~ ^/(.*) { + return 302 http://alpha.editor.p5js.org/$1; + } +} + +server { + listen 443; + ssl on; + ssl_certificate /etc/letsencrypt/live/editor.p5js.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/editor.p5js.org/privkey.pem; + server_name editor.p5js.org; + location ~ ^/(.*) { + return 302 https://alpha.editor.p5js.org/$1; + } +} \ No newline at end of file diff --git a/nginx/nginx-aws.conf b/nginx/nginx-aws.conf new file mode 100644 index 00000000..b0ab9feb --- /dev/null +++ b/nginx/nginx-aws.conf @@ -0,0 +1,122 @@ +# For more information on configuration, see: +# * Official English Documentation: http://nginx.org/en/docs/ +# * Official Russian Documentation: http://nginx.org/ru/docs/ + +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Load modular configuration files from the /etc/nginx/conf.d directory. + # See http://nginx.org/en/docs/ngx_core_module.html#include + # for more information. + include /etc/nginx/conf.d/*.conf; + + include /etc/nginx/sites-enabled/*.conf; + + index index.html index.htm; + + server { + listen 80 default_server; + listen [::]:80 default_server; + server_name localhost; + root /usr/share/nginx/html; + + # Load configuration files for the default server block. + include /etc/nginx/default.d/*.conf; + + location / { + } + + # redirect server error pages to the static page /40x.html + # + error_page 404 /404.html; + location = /40x.html { + } + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } + + +# Settings for a TLS enabled server. +# +# server { +# listen 443 ssl; +# listen [::]:443 ssl; +# server_name localhost; +# root /usr/share/nginx/html; +# +# ssl_certificate "/etc/pki/nginx/server.crt"; +# ssl_certificate_key "/etc/pki/nginx/private/server.key"; +# # It is *strongly* recommended to generate unique DH parameters +# # Generate them with: openssl dhparam -out /etc/pki/nginx/dhparams.pem 2048 +# #ssl_dhparam "/etc/pki/nginx/dhparams.pem"; +# ssl_session_cache shared:SSL:1m; +# ssl_session_timeout 10m; +# ssl_protocols TLSv1 TLSv1.1 TLSv1.2; +# ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP; +# ssl_prefer_server_ciphers on; +# +# # Load configuration files for the default server block. +# include /etc/nginx/default.d/*.conf; +# +# location / { +# } +# +# error_page 404 /404.html; +# location = /40x.html { +# } +# +# error_page 500 502 503 504 /50x.html; +# location = /50x.html { +# } +# } + +} \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf index ec704743..e69de29b 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,61 +0,0 @@ - # HTTP - redirect all requests to HTTPS: - server { - listen 80; - server_name alpha.editor.p5js.org; - location / { - proxy_pass http://127.0.0.1:8000; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - } - location ~* \/login(\/)* { - return 301 https://$host$request_uri; - } - location ~* \/signup(\/)* { - return 301 https://$host$request_uri; - } - location ~* \/reset-password(\/)* { - return 301 https://$host$request_uri; - } - location ~* "\/[a-zA-Z0-9._-]{1,20}\/account(\/)*" { - return 301 https://$host$request_uri; - } - -} - -server { - listen 443; - ssl on; - ssl_certificate /etc/letsencrypt/live/alpha.editor.p5js.org/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/alpha.editor.p5js.org/privkey.pem; - server_name alpha.editor.p5js.org; - location / { - proxy_pass http://127.0.0.1:8000; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - } -} - -server { - listen 80; - server_name editor.p5js.org; - location ~ ^/(.*) { - return 302 http://alpha.editor.p5js.org/$1; - } -} - -server { - listen 443; - ssl on; - ssl_certificate /etc/letsencrypt/live/editor.p5js.org/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/editor.p5js.org/privkey.pem; - server_name editor.p5js.org; - location ~ ^/(.*) { - return 302 https://alpha.editor.p5js.org/$1; - } -} \ No newline at end of file