Skip to content

Instantly share code, notes, and snippets.

@pulasthi7
Last active May 3, 2021 09:10
Show Gist options
  • Save pulasthi7/b3580a5ee6fb0b2d928ad99837074d43 to your computer and use it in GitHub Desktop.
Save pulasthi7/b3580a5ee6fb0b2d928ad99837074d43 to your computer and use it in GitHub Desktop.
Nginx conf for tenanted sessions
server {
listen 443;
server_name accounts.asg.io;
ssl on;
ssl_certificate /usr/local/etc/nginx/ssl/asg_nginx.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/asg_key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ~ ^/t/a/common(?<path>/.*) {
rewrite ^ $path?t=carbon.super break;
proxy_pass https://localhost:9443;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_redirect ~^(?<domain>https://[^/]+)/t/carbon.super(?<suffix>.*)$ $domain/t/a$suffix;
proxy_cookie_path /t/carbon.super /t/a;
}
location ~ "^/t/(?<t>[a-z0-9.\-_]{4,})/common(?<path>/.*)" {
rewrite ^ $path?t=$t break;
proxy_pass https://localhost:9443;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
}
location ~ ^/t/a(?<path>/.*) {
rewrite ^ $path?t=carbon.super break;
proxy_pass https://localhost:9443;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_redirect https://accounts.asg.io/authenticationendpoint https://accounts.asg.io/t/a/authenticationendpoint;
proxy_redirect ~^(?<domain>https://[^/]+)/t/carbon.super(?<suffix>.*)$ $domain/t/a$suffix;
proxy_cookie_path /t/carbon.super /t/a;
}
location / {
proxy_pass https://localhost:9443;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_redirect ~^(?<domain>https://[^/]+)/t/carbon.super(?<suffix>.*)$ $domain/t/a$suffix;
proxy_cookie_path /t/carbon.super /t/a;
}
}
server {
listen 443;
server_name console.asg.io;
ssl on;
ssl_certificate /usr/local/etc/nginx/ssl/asg_nginx.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/asg_key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ~ ^/t/(?<t>[a-z0-9.\-_]+)/(?<path>.*) {
proxy_pass https://localhost:9443/t/$t/console/$path;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_cookie_path /console /;
}
location ~ ^/t/(?<t>[a-z0-9.\-_]+) {
proxy_pass https://localhost:9443/t/$t/console/;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_cookie_path /console /;
}
location / {
proxy_pass https://localhost:9443/console/;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_cookie_path /console /;
}
}
server {
listen 443;
server_name myaccount.asg.io;
ssl on;
ssl_certificate /usr/local/etc/nginx/ssl/asg_nginx.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/asg_key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ~ ^/t/(?<t>[a-z0-9.\-_]+)/(?<path>.*) {
proxy_pass https://localhost:9443/t/$t/myaccount/$path;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_cookie_path /myaccount /;
}
location ~ ^/t/(?<t>[a-z0-9.\-_]+) {
proxy_pass https://localhost:9443/t/$t/myaccount/;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_cookie_path /myaccount /;
}
location / {
proxy_pass https://localhost:9443/myaccount/;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_http_version 1.1;
proxy_cookie_path /myaccount /;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment