-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
312 additions
and
147 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
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
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,20 @@ | ||
from vergilius.config import PROXY_PORTS | ||
|
||
allocated = set() | ||
|
||
|
||
def allocate(): | ||
min_port = PROXY_PORTS[0] | ||
max_port = PROXY_PORTS[1] | ||
|
||
while min_port < max_port: | ||
if min_port not in allocated: | ||
allocated.add(min_port) | ||
return min_port | ||
min_port += 1 | ||
|
||
raise Exception('Failed to allocate port') | ||
|
||
|
||
def release(port): | ||
allocated.discard(int(port)) |
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
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
{% whitespace all%} | ||
{% if len(service.binds['http']) %} | ||
server { | ||
server_name{% for domain in service.binds['http'] %} {{ domain }} *.{{ domain }}{% end %}; | ||
listen {{config.NGINX_HTTP_PORT}}; | ||
|
||
{% if len(service.binds['http']) %} | ||
location / { | ||
proxy_pass http://{{service.id}}; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
{% if service.allow_crossdomain %} | ||
proxy_hide_header 'Access-Control-Allow-Origin'; | ||
add_header 'Access-Control-Allow-Origin' "$http_origin"; | ||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; | ||
add_header 'Access-Control-Allow-Credentials' 'true'; | ||
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cookie,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'; | ||
|
||
if ($request_method = 'OPTIONS' ) { | ||
# if request method is options we immediately return with 200 OK. | ||
return 200; | ||
} | ||
{% end %} | ||
} | ||
{% else %} | ||
location / { | ||
return 301 https://$server_name$request_uri; | ||
} | ||
{% end %} | ||
} | ||
{% end %} |
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,31 @@ | ||
{% whitespace all%} | ||
{% if len(service.binds['http2']) and service.certificate.private_key and service.certificate.public_key %} | ||
server { | ||
server_name{% for domain in service.binds['http2'] %} {{ domain }} *.{{ domain }}{% end %}; | ||
listen {{config.NGINX_HTTP2_PORT}} ssl http2; | ||
|
||
ssl_certificate {{service.certificate.get_cert_path()}}; | ||
ssl_certificate_key {{service.certificate.get_key_path()}}; | ||
|
||
location / { | ||
proxy_pass http://{{service.id}}; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
{% if service.allow_crossdomain %} | ||
proxy_hide_header 'Access-Control-Allow-Origin'; | ||
add_header 'Access-Control-Allow-Origin' "$http_origin"; | ||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; | ||
add_header 'Access-Control-Allow-Credentials' 'true'; | ||
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cookie,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'; | ||
|
||
if ($request_method = 'OPTIONS' ) { | ||
# if request method is options we immediately return with 200 OK. | ||
return 200; | ||
} | ||
{% end %} | ||
} | ||
} | ||
{% end %} |
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,7 @@ | ||
{% whitespace all%} | ||
{% if len(service.binds['tcp']) %} | ||
server { | ||
listen {{service.port}}; | ||
proxy_pass {{service.id}}; | ||
} | ||
{% end %} |
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,7 @@ | ||
{% whitespace all%} | ||
{% if len(service.binds['udp']) %} | ||
server { | ||
listen {{service.port}} udp; | ||
proxy_pass {{service.id}}; | ||
} | ||
{% end %} |
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,8 @@ | ||
{% whitespace all%} | ||
upstream {{service.id}} { | ||
hash $remote_addr consistent; | ||
|
||
{% for node_name in service.nodes %}server {{ service.nodes[node_name]['address'] }}:{{ service.nodes[node_name]['port'] }}; | ||
{% end %} | ||
{% if not service.nodes %}server 127.0.0.1:6666;{% end %} | ||
} |
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
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