get nginx proxying working on local machine

This commit is contained in:
Cassie Tarakajian 2018-06-19 15:22:18 -07:00
parent c7ce85e0d7
commit d4b927f0d4
6 changed files with 85 additions and 76 deletions

View file

@ -1,3 +1,12 @@
language: node_js
node_js:
- "8.11.1"
services:
- docker
before_install:
# eventually set up AWS stuff here
- docker-compose up -d
- docker ps -a

View file

@ -30,6 +30,7 @@ RUN npm install pm2 -g
RUN npm install local-ssl-proxy
COPY index.js ecosystem.json ./
COPY --from=build /usr/src/app/dist ./dist
RUN npm run ssl-proxy
#RUN npm run fetch-examples:prod
# for reg production
CMD ["pm2-runtime", "ecosystem.json"]
# for testing ssl locally
# CMD npm run ssl-proxy && pm2-runtime ecosystem.json

View file

@ -6,9 +6,11 @@ services:
- dbdata:/data/db
expose:
- "27017"
# nginx:
# build: ./nginx
server:
nginx:
build: ./nginx
ports:
- '80:80'
app:
build:
context: .
dockerfile: Dockerfile
@ -17,15 +19,14 @@ services:
- .env
environment:
- MONGO_URL=mongodb://mongo:27017/p5js-web-editor
- API_URL=https://localhost/api
- PORT=80
# - API_URL=https://localhost/api
# - PORT=80
volumes:
- .:/opt/node/app
- /opt/node/app/node_modules
ports:
- '8000:8000'
- '80:80'
- '443:443'
# - '443:443'
depends_on:
- mongo
volumes:

View file

@ -1,5 +1,3 @@
FROM nginx:1.13.12
RUN mkdir -p /etc/nginx/sites-enabled
COPY nginx.conf /etc/nginx/nginx.conf
COPY alpha.editor.p5js.org.conf /etc/nginx/sites-enabled
COPY alpha.editor.p5js.org.conf /etc/nginx/conf.d/default.conf

View file

@ -1,27 +1,27 @@
# HTTP - redirect all requests to HTTPS:
server {
listen 80;
server_name alpha.editor.p5js.org;
#server_name alpha.editor.p5js.org;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_pass http://app: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;
}
# 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;
# }
}
@ -41,13 +41,13 @@
# }
# }
server {
listen 80;
server_name editor.p5js.org;
location ~ ^/(.*) {
return 302 http://alpha.editor.p5js.org/$1;
}
}
# server {
# listen 80;
# server_name editor.p5js.org;
# location ~ ^/(.*) {
# return 302 http://alpha.editor.p5js.org/$1;
# }
# }
# server {
# listen 443;

View file

@ -30,59 +30,59 @@ http {
# 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/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
index index.html index.htm;
# index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/nginx/html;
# 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;
# # 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;
# location / {
# }
# 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;
# # redirect server error pages to the static page /40x.html
# #
# error_page 404 /404.html;
# location = /40x.html {
# }
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
# # 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.