From 8b5c005a39ba19e2cb084064a08b8b9ad96a53fc Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 May 2020 03:53:23 +0100 Subject: [PATCH] New templates for nginx configurations --- sites/default.conf | 14 ----- sites/legacy.conf | 34 ------------- sites/vanilla.conf | 34 ------------- templates/sites/legacy.conf.template | 52 +++++++++++++++++++ templates/sites/vanilla.conf.template | 73 +++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 82 deletions(-) delete mode 100644 sites/default.conf delete mode 100644 sites/legacy.conf delete mode 100644 sites/vanilla.conf create mode 100644 templates/sites/legacy.conf.template create mode 100644 templates/sites/vanilla.conf.template diff --git a/sites/default.conf b/sites/default.conf deleted file mode 100644 index d533c62..0000000 --- a/sites/default.conf +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen 80 default_server; - server_name _; - - location /play { - root /usr/share/nginx/legacy/; - index index.html index.htm; - } - - location /media { - root /usr/share/nginx/legacy/; - index index.html index.htm; - } -} diff --git a/sites/legacy.conf b/sites/legacy.conf deleted file mode 100644 index 767985c..0000000 --- a/sites/legacy.conf +++ /dev/null @@ -1,34 +0,0 @@ -server { - server_name play.*; - - location / { - root /usr/share/nginx/legacy/play; - index index.html index.htm; - } - - location /create_account/create_account.php { - proxy_pass http://dash:3000/create; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - - location /create/activate { - proxy_pass http://localhost:3000/create/activate; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -} - -server { - server_name media.*; - - location / { - root /usr/share/nginx/legacy/media; - index index.html index.htm; - } - -} diff --git a/sites/vanilla.conf b/sites/vanilla.conf deleted file mode 100644 index 683ff8c..0000000 --- a/sites/vanilla.conf +++ /dev/null @@ -1,34 +0,0 @@ -server { - server_name new.*; - - location / { - root /usr/share/nginx/vanilla/play; - index index.html index.htm; - } - - location ~ ^/avatar/(.*)/cp$ { - proxy_pass http://dash:3000/avatar/$1$is_args$args; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - -} - -server { - server_name vanilla.*; - - location / { - root /usr/share/nginx/vanilla/media; - index index.html index.htm; - } - - location /social/autocomplete/v2/search/suggestions { - proxy_pass http://localhost:3000/autocomplete; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -} diff --git a/templates/sites/legacy.conf.template b/templates/sites/legacy.conf.template new file mode 100644 index 0000000..4e7b2bd --- /dev/null +++ b/templates/sites/legacy.conf.template @@ -0,0 +1,52 @@ +server { + server_name {{ (parseUrl .Env.WEB_LEGACY_PLAY).Host }}; + + {{ if (parseUrl .Env.WEB_LEGACY_PLAY).Path }} + location {{ (parseUrl .Env.WEB_LEGACY_PLAY).Path }} { + root /usr/share/nginx/legacy/; + index index.html index.htm; + } + location / { + root /usr/share/nginx/legacy/{{ (parseUrl .Env.WEB_LEGACY_PLAY).Path }}; + index index.html index.htm; + } + location {{ (parseUrl .Env.WEB_LEGACY_MEDIA).Path }} { + root /usr/share/nginx/legacy/; + index index.html index.htm; + } + location {{ (parseUrl .Env.WEB_LEGACY_PLAY).Path }}/v2 { + root /usr/share/nginx/legacy/media/; + } + {{ else }} + location / { + root /usr/share/nginx/legacy/play; + index index.html index.htm; + } + {{ end }} + + location /create_account/create_account.php { + proxy_pass http://dash:3000/create/legacy; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /create/activate { + proxy_pass http://dash:3000/create/activate; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +server { + server_name {{ (parseUrl .Env.WEB_LEGACY_MEDIA).Host }}; + + location / { + root /usr/share/nginx/legacy/media; + index index.html index.htm; + } + +} diff --git a/templates/sites/vanilla.conf.template b/templates/sites/vanilla.conf.template new file mode 100644 index 0000000..e3791ce --- /dev/null +++ b/templates/sites/vanilla.conf.template @@ -0,0 +1,73 @@ +server { + server_name {{ (parseUrl .Env.WEB_VANILLA_PLAY).Host }}; + + location {{ (parseUrl .Env.WEB_VANILLA_PLAY).Path }}/ { + root /usr/share/nginx/vanilla/play/; + index index.html index.htm; + } + + location /penguin/create { + proxy_pass http://dash:3000/create/vanilla/en; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location ~ ^/(.*)/penguin/create { + proxy_pass http://dash:3000/create/vanilla/$1; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location ~ ^/(.*)/penguin/activate { + proxy_pass http://dash:3000/activate/vanilla/$1; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location ~ ^/avatar/(.*)/cp$ { + proxy_pass http://dash:3000/avatar/$1$is_args$args; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location ^/(.*)/web-service/snfgenerator/session$ { + proxy_pass http://dash:3000/session; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /api/v0.2/xxx/game/get/world-name-service/start_world_request { + proxy_pass http://dash:3000/swrequest; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +server { + server_name {{ (parseUrl .Env.WEB_VANILLA_MEDIA).Host }}; + + location / { + root /usr/share/nginx/vanilla/media; + index index.html index.htm; + } + + location /social/autocomplete/v2/search/suggestions { + proxy_pass http://dash:3000/autocomplete; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +}