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

Reverse proxy configurations for nginx, for development as well as production #25

Open
wants to merge 1 commit into
base: kosugi/angular-docker
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions angular/nginx/conf.d.prod/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
worker_processes 4;

events {
worker_connections 1024;
}

http {
server {
listen 443 ssl;
server_name panomicon.nibiohn.go.jp;
ssl_certificate /etc/nginx/cert/xxx.crt
ssl_certificate_key /etc/nginx/cert/xxx.key

root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;

gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

location / {
try_files $uri $uri/ /index.html;
}

# Reverse proxy for angular to talk to scalatra
location /json {
proxy_pass http://scalatra:8888;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host:4200;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

}
}

server {
listen 443 ssl;
server_name panomicon-auth.nibiohn.go.jp;
ssl_certificate /etc/nginx/cert/xxx.crt
ssl_certificate_key /etc/nginx/cert/xxx.key

# Forward all requests to fusionauth
location / {
proxy_pass http://fusionauth:9011;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

}
41 changes: 41 additions & 0 deletions angular/nginx/conf.d/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;

gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

# location = / {
# try_files /index.html =404;
# }

location / {
try_files $uri $uri/ /index.html;
}

# Docker nginx reverse proxy proxy_pass entry
location /json {
proxy_pass http://scalatra:8888;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host:4200;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
30 changes: 1 addition & 29 deletions angular/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;

gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

# location = / {
# try_files /index.html =404;
# }

location / {
try_files $uri $uri/ /index.html;
}
}
}
include conf.d/default;
17 changes: 17 additions & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,27 @@ services:
volumes:
- ${T_DATA_DIR}:/data

node:
build:
context: angular/
dockerfile: "Dockerfile"
depends_on:
- scalatra
- fusionauth
ports:
- "4200:80"
tty: true
restart: unless-stopped
networks:
- panomicon_net
volumes:
- ./angular/nginx/conf.d:/etc/nginx/conf.d

networks:
panomicon_net:
driver: bridge

volumes:
fusionauth_db_data:
fusionauth_config:

Loading