-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
daemon off; | ||
worker_processes 4; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
default_type application/octet-stream; | ||
|
||
upstream stf_app { | ||
server 172.17.8.[101|102|103]:3100 max_fails=0; | ||
} | ||
|
||
upstream stf_auth { | ||
server 172.17.8.[101|102|103]:3200 max_fails=0; | ||
} | ||
|
||
upstream stf_storage_apk { | ||
server 172.17.8.[101|102|103]:3300 max_fails=0; | ||
} | ||
|
||
upstream stf_storage_image { | ||
server 172.17.8.[101|102|103]:3400 max_fails=0; | ||
} | ||
|
||
upstream stf_storage { | ||
server 172.17.8.[101|102|103]:3500 max_fails=0; | ||
} | ||
|
||
upstream stf_websocket { | ||
server 172.17.8.[101|102|103]:3600 max_fails=0; | ||
} | ||
|
||
types { | ||
application/javascript js; | ||
image/gif gif; | ||
image/jpeg jpg; | ||
text/css css; | ||
text/html html; | ||
} | ||
|
||
map $http_upgrade $connection_upgrade { | ||
default upgrade; | ||
'' close; | ||
} | ||
|
||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
server_name stf.mydomain.org; | ||
root /dev/null; | ||
|
||
|
||
resolver 8.8.4.4 8.8.8.8 valid=300s; | ||
resolver_timeout 10s; | ||
|
||
location ~ "^/d/1/([^/]+)/(?<port>[0-9]{5})/$" { | ||
proxy_pass http://172.17.8.102:$port/; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_set_header X-Forwarded-For $remote_addr; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
|
||
location ~ "^/d/2/([^/]+)/(?<port>[0-9]{5})/$" { | ||
proxy_pass http://172.17.8.103:$port/; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_set_header X-Forwarded-For $remote_addr; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
|
||
location ~ "^/d/3/([^/]+)/(?<port>[0-9]{5})/$" { | ||
proxy_pass http://172.17.8.101:$port/; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_set_header X-Forwarded-For $remote_addr; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
|
||
location /s/image/ { | ||
proxy_pass http://stf_storage_image; | ||
} | ||
|
||
location /s/apk/ { | ||
proxy_pass http://stf_storage_apk; | ||
} | ||
|
||
location /s/ { | ||
client_max_body_size 1024m; | ||
client_body_buffer_size 128k; | ||
proxy_pass http://stf_storage; | ||
} | ||
|
||
location /socket.io/ { | ||
proxy_pass http://stf_websocket; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Real-IP $http_x_real_ip; | ||
} | ||
|
||
location /auth/ { | ||
proxy_pass http://stf_auth/auth/; | ||
} | ||
|
||
location / { | ||
proxy_pass http://stf_app; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Real-IP $http_x_real_ip; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[Unit] | ||
Description=STF nginx public load balancer | ||
After=docker.service | ||
Requires=docker.service | ||
ConditionPathExists=/srv/nginx/nginx.conf | ||
|
||
[Service] | ||
EnvironmentFile=/etc/environment | ||
TimeoutStartSec=0 | ||
Restart=always | ||
ExecStartPre=/usr/bin/docker pull nginx:1.7.10 | ||
ExecStartPre=-/usr/bin/docker kill %p | ||
ExecStartPre=-/usr/bin/docker rm %p | ||
ExecStart=/usr/bin/docker run --rm \ | ||
--name %p \ | ||
--net host \ | ||
-v /srv/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \ | ||
nginx:1.7.10 \ | ||
nginx | ||
ExecStop=/usr/bin/docker stop -t 2 %p |