158 lines
4.2 KiB
Nginx Configuration File
158 lines
4.2 KiB
Nginx Configuration File
upstream sal {
|
|
server unix:/opt/pg/tmp/sal-web.socket;
|
|
keepalive 16;
|
|
}
|
|
|
|
upstream websocket {
|
|
server unix:/opt/pg/tmp/sal-ws.socket;
|
|
keepalive 16;
|
|
}
|
|
|
|
upstream pgCli {
|
|
server {{ virtual_ip }}:3000;
|
|
}
|
|
|
|
upstream pgMW {
|
|
server {{ opsvm_ip }}:4000;
|
|
}
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
lua_socket_log_errors off;
|
|
#lua_code_cache off;
|
|
lua_shared_dict rest_servers 16K;
|
|
lua_shared_dict apache_servers 16K;
|
|
lua_shared_dict tc_servers 16K;
|
|
init_by_lua 'lb = require "lb"
|
|
init_servers = {
|
|
{% for ip in director_ips -%}
|
|
["{{ ip }}"] = true,
|
|
{% endfor -%}
|
|
}';
|
|
|
|
# Redirect http to https
|
|
server {
|
|
listen {{ virtual_ip }}:9080;
|
|
server_name $hostname;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen {{ virtual_ip }}:443 ssl;
|
|
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
|
|
ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
|
|
ssl_certificate /opt/pg/sal/nginx/ssl/default.crt;
|
|
ssl_certificate_key /opt/pg/sal/nginx/ssl/default.key;
|
|
#ssl_session_cache shared:SSL:10m;
|
|
#ssl_session_timeout 10m;
|
|
|
|
server_name $hostname;
|
|
root /opt/pg/web;
|
|
index login.html;
|
|
|
|
location /cli/ {
|
|
proxy_pass http://pgCli/;
|
|
proxy_redirect off;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
location /mwv0 {
|
|
proxy_pass http://pgMW;
|
|
proxy_redirect off;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
location /cloudApex/ {
|
|
index index.html;
|
|
}
|
|
|
|
location /vtap/ {
|
|
alias /opt/pg/vtap;
|
|
}
|
|
|
|
# REST API calls start with /v[0-9]/, a keyword, or a capital letter.
|
|
# Note: Regular expressions have higher precedence than prefix matches
|
|
# so don't combine with /0/...
|
|
location ~ ^/(v[0-9]/|pg/|docs|api-docs|[A-Z]) {
|
|
set $active_upstream "http://sal";
|
|
access_by_lua 'if ngx.req.get_uri_args()["server"]~=nil then
|
|
if ngx.req.get_uri_args()["server"]~=ngx.var.host then
|
|
ngx.var.active_upstream = "https://"..ngx.req.get_uri_args()["server"]..ngx.var.request_uri
|
|
end
|
|
end';
|
|
|
|
proxy_pass $active_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
location /0/ {
|
|
set $active_upstream "http://sal";
|
|
access_by_lua 'if ngx.req.get_uri_args()["server"]~=nil then
|
|
if ngx.req.get_uri_args()["server"]~=ngx.var.host then
|
|
ngx.var.active_upstream = "https://"..ngx.req.get_uri_args()["server"]..ngx.var.request_uri
|
|
end
|
|
end';
|
|
|
|
proxy_pass $active_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
location /0/websocket {
|
|
set $active_upstream "http://websocket";
|
|
access_by_lua 'if ngx.req.get_uri_args()["server"]~=nil then
|
|
if ngx.req.get_uri_args()["server"]~=ngx.var.host then
|
|
ngx.var.active_upstream = "https://"..ngx.req.get_uri_args()["server"]..ngx.var.request_uri
|
|
end
|
|
end';
|
|
proxy_pass $active_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen unix:/opt/pg/tmp/sal-rest.socket;
|
|
|
|
# debug socket
|
|
listen 127.0.0.1:9080;
|
|
|
|
location / {
|
|
set $active_upstream "";
|
|
access_by_lua 'ngx.var.active_upstream = find_next(ngx.shared.rest_servers, 9180)';
|
|
proxy_pass http://$active_upstream:9180;
|
|
}
|
|
|
|
location /_debug/rest_servers {
|
|
access_by_lua 'find_next(ngx.shared.rest_servers, 9180)';
|
|
content_by_lua '
|
|
for _, ip in pairs(ngx.shared.rest_servers:get_keys()) do
|
|
ngx.say(ip.."="..ngx.shared.rest_servers:get(ip))
|
|
end
|
|
';
|
|
}
|
|
|
|
location /_debug/tc_servers {
|
|
access_by_lua 'find_next(ngx.shared.tc_servers, 12349)';
|
|
content_by_lua '
|
|
for _, ip in pairs(ngx.shared.tc_servers:get_keys()) do
|
|
ngx.say(ip.."="..ngx.shared.tc_servers:get(ip))
|
|
end
|
|
';
|
|
}
|
|
}
|
|
|