From b24b24a672176448017c019ded38c6ef11af5463 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 3 Dec 2023 19:23:01 +0200 Subject: [PATCH] refactor opennet conf --- nginx/opennet/README.md | 16 ++++++---- .../handle => handles}/redirect.conf | 2 +- nginx/opennet/locations.conf | 29 +++++++++---------- nginx/opennet/locations/bsd.conf | 2 +- nginx/opennet/locations/cisco.conf | 2 +- nginx/opennet/locations/grab.conf | 2 +- nginx/opennet/locations/include/common.conf | 2 +- nginx/opennet/locations/linux.conf | 2 +- nginx/opennet/locations/m.conf | 2 +- nginx/opennet/locations/mobile.conf | 2 +- nginx/opennet/locations/palm.conf | 2 +- nginx/opennet/locations/security.conf | 2 +- nginx/opennet/locations/solaris.conf | 2 +- nginx/opennet/locations/web.conf | 2 +- nginx/opennet/locations/wiki.conf | 2 +- nginx/opennet/locations/www-less.conf | 2 +- nginx/opennet/locations/www.conf | 2 +- nginx/opennet/server.conf | 11 ++++--- 18 files changed, 46 insertions(+), 40 deletions(-) rename nginx/opennet/{locations/handle => handles}/redirect.conf (73%) diff --git a/nginx/opennet/README.md b/nginx/opennet/README.md index f8da7c4..13d270b 100644 --- a/nginx/opennet/README.md +++ b/nginx/opennet/README.md @@ -1,4 +1,4 @@ -# Nginx proxy configuration for OpenNet +# Nginx proxy configuration for OpenNet located at subfolder Current implementation forward subdomains to following proxy locations: @@ -17,11 +17,17 @@ Current implementation forward subdomains to following proxy locations: * `wiki.opennet.ru` > `/opennet/wiki` * `forum.opennet.ru` > `/opennet/wwwcgi-bin/openforum/vsluhboard.cgi` -## Installation +## Install -1. Download `nginx/opennet` content to `/etc/nginx/opennet` folder -2. Copy `nginx/opennet/server.conf` to `/etc/nginx/sites-available/opennet.conf` then change commented options for your needs -3. Alternatively, include `nginx/opennet/locations.conf` to existing website config at `sites-available` then reload nginx configuration +* `ln -s /etc/yggbro/nginx/opennet/server.conf /etc/nginx/sites-enabled/yggbro.opennet.conf` +* `nginx -t` +* `service nginx reload` + +## Uninstall + +* `rm /etc/nginx/sites-enabled/yggbro.opennet.conf` +* `nginx -t` +* `service nginx reload` ## Issues diff --git a/nginx/opennet/locations/handle/redirect.conf b/nginx/opennet/handles/redirect.conf similarity index 73% rename from nginx/opennet/locations/handle/redirect.conf rename to nginx/opennet/handles/redirect.conf index 7f268d1..16ea617 100644 --- a/nginx/opennet/locations/handle/redirect.conf +++ b/nginx/opennet/handles/redirect.conf @@ -1,6 +1,6 @@ # Prevent out redirects (solution for issue #2) -location @opennet_locations_handle_redirect { +location @yggbro_nginx_opennet_handles_redirect { set $original_uri $uri; set $orig_loc $upstream_http_location; diff --git a/nginx/opennet/locations.conf b/nginx/opennet/locations.conf index 04fcba8..1fe4e57 100644 --- a/nginx/opennet/locations.conf +++ b/nginx/opennet/locations.conf @@ -1,41 +1,38 @@ # www-less -include /etc/nginx/opennet/locations/www-less.conf; +include /etc/yggbro/nginx/opennet/locations/www-less.conf; # www -include /etc/nginx/opennet/locations/www.conf; +include /etc/yggbro/nginx/opennet/locations/www.conf; # bsd -include /etc/nginx/opennet/locations/bsd.conf; +include /etc/yggbro/nginx/opennet/locations/bsd.conf; # cisco -include /etc/nginx/opennet/locations/cisco.conf; +include /etc/yggbro/nginx/opennet/locations/cisco.conf; # grab -include /etc/nginx/opennet/locations/grab.conf; +include /etc/yggbro/nginx/opennet/locations/grab.conf; # linux -include /etc/nginx/opennet/locations/linux.conf; +include /etc/yggbro/nginx/opennet/locations/linux.conf; # m -include /etc/nginx/opennet/locations/m.conf; +include /etc/yggbro/nginx/opennet/locations/m.conf; # mobile -include /etc/nginx/opennet/locations/mobile.conf; +include /etc/yggbro/nginx/opennet/locations/mobile.conf; # palm -include /etc/nginx/opennet/locations/palm.conf; +include /etc/yggbro/nginx/opennet/locations/palm.conf; # security -include /etc/nginx/opennet/locations/security.conf; +include /etc/yggbro/nginx/opennet/locations/security.conf; # solaris -include /etc/nginx/opennet/locations/solaris.conf; +include /etc/yggbro/nginx/opennet/locations/solaris.conf; # web -include /etc/nginx/opennet/locations/web.conf; +include /etc/yggbro/nginx/opennet/locations/web.conf; # wiki -include /etc/nginx/opennet/locations/wiki.conf; - -# handles (do not delete) -include /etc/nginx/opennet/locations/handle/redirect.conf; \ No newline at end of file +include /etc/yggbro/nginx/opennet/locations/wiki.conf; \ No newline at end of file diff --git a/nginx/opennet/locations/bsd.conf b/nginx/opennet/locations/bsd.conf index 38614eb..8f2d8bb 100644 --- a/nginx/opennet/locations/bsd.conf +++ b/nginx/opennet/locations/bsd.conf @@ -4,7 +4,7 @@ location /opennet/bsd { proxy_pass https://bsd.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/bsd/'; diff --git a/nginx/opennet/locations/cisco.conf b/nginx/opennet/locations/cisco.conf index d524453..5b387c0 100644 --- a/nginx/opennet/locations/cisco.conf +++ b/nginx/opennet/locations/cisco.conf @@ -4,7 +4,7 @@ location /opennet/cisco { proxy_pass https://cisco.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/cisco/'; diff --git a/nginx/opennet/locations/grab.conf b/nginx/opennet/locations/grab.conf index 4878b42..ac3fe7b 100644 --- a/nginx/opennet/locations/grab.conf +++ b/nginx/opennet/locations/grab.conf @@ -4,7 +4,7 @@ location /opennet/grab { proxy_pass https://grab.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/grab/'; diff --git a/nginx/opennet/locations/include/common.conf b/nginx/opennet/locations/include/common.conf index 3aa0179..01c7ab2 100644 --- a/nginx/opennet/locations/include/common.conf +++ b/nginx/opennet/locations/include/common.conf @@ -8,7 +8,7 @@ proxy_set_header X-Real-IP $remote_addr; # Prevent out redirects (issue #2) proxy_intercept_errors on; -error_page 301 302 307 = @opennet_locations_handle_redirect; +error_page 301 302 307 = @yggbro_nginx_opennet_handles_redirect; # Replace all matches sub_filter_once off; diff --git a/nginx/opennet/locations/linux.conf b/nginx/opennet/locations/linux.conf index c19a72f..ff63db3 100644 --- a/nginx/opennet/locations/linux.conf +++ b/nginx/opennet/locations/linux.conf @@ -4,7 +4,7 @@ location /opennet/linux { proxy_pass https://linux.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/linux/'; diff --git a/nginx/opennet/locations/m.conf b/nginx/opennet/locations/m.conf index 170c319..63cd290 100644 --- a/nginx/opennet/locations/m.conf +++ b/nginx/opennet/locations/m.conf @@ -4,7 +4,7 @@ location /opennet/m { proxy_pass https://m.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/m/'; diff --git a/nginx/opennet/locations/mobile.conf b/nginx/opennet/locations/mobile.conf index 97b3487..29d78e1 100644 --- a/nginx/opennet/locations/mobile.conf +++ b/nginx/opennet/locations/mobile.conf @@ -4,7 +4,7 @@ location /opennet/mobile { proxy_pass https://mobile.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/mobile/'; diff --git a/nginx/opennet/locations/palm.conf b/nginx/opennet/locations/palm.conf index 0567dd8..673f738 100644 --- a/nginx/opennet/locations/palm.conf +++ b/nginx/opennet/locations/palm.conf @@ -4,7 +4,7 @@ location /opennet/palm { proxy_pass https://palm.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/palm/'; diff --git a/nginx/opennet/locations/security.conf b/nginx/opennet/locations/security.conf index a5e6305..0a75a6d 100644 --- a/nginx/opennet/locations/security.conf +++ b/nginx/opennet/locations/security.conf @@ -4,7 +4,7 @@ location /opennet/security { proxy_pass https://security.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/security/'; diff --git a/nginx/opennet/locations/solaris.conf b/nginx/opennet/locations/solaris.conf index 83c82b1..7258fd0 100644 --- a/nginx/opennet/locations/solaris.conf +++ b/nginx/opennet/locations/solaris.conf @@ -4,7 +4,7 @@ location /opennet/solaris { proxy_pass https://solaris.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/solaris/'; diff --git a/nginx/opennet/locations/web.conf b/nginx/opennet/locations/web.conf index 1c8d17d..430c058 100644 --- a/nginx/opennet/locations/web.conf +++ b/nginx/opennet/locations/web.conf @@ -4,7 +4,7 @@ location /opennet/web { proxy_pass https://web.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/web/'; diff --git a/nginx/opennet/locations/wiki.conf b/nginx/opennet/locations/wiki.conf index 512fa3c..1d98691 100644 --- a/nginx/opennet/locations/wiki.conf +++ b/nginx/opennet/locations/wiki.conf @@ -4,7 +4,7 @@ location /opennet/wiki { proxy_pass https://wiki.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/wiki/'; diff --git a/nginx/opennet/locations/www-less.conf b/nginx/opennet/locations/www-less.conf index 8140d0f..d68a9ce 100644 --- a/nginx/opennet/locations/www-less.conf +++ b/nginx/opennet/locations/www-less.conf @@ -4,7 +4,7 @@ location /opennet { proxy_pass https://opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/opennet/'; diff --git a/nginx/opennet/locations/www.conf b/nginx/opennet/locations/www.conf index ad3cd89..236cb14 100644 --- a/nginx/opennet/locations/www.conf +++ b/nginx/opennet/locations/www.conf @@ -4,7 +4,7 @@ location /opennet/www { proxy_pass https://www.opennet.ru/; # Include common rules - include /etc/nginx/opennet/locations/include/common.conf; + include /etc/yggbro/nginx/opennet/locations/include/common.conf; # Relative paths sub_filter 'action="/' 'action="http://[$server_addr]/opennet/www/'; diff --git a/nginx/opennet/server.conf b/nginx/opennet/server.conf index a0721a5..7cc922a 100644 --- a/nginx/opennet/server.conf +++ b/nginx/opennet/server.conf @@ -1,12 +1,15 @@ server { # HTTP/IPv6 connections only - # listen [::]:80 ipv6only=on _; + listen [::]:80; # Yggdrasil connections only - # allow 0200::/7; - # deny all; + allow 0200::/7; + deny all; + + # Include handles + include /etc/yggbro/nginx/opennet/handles/redirect.conf; # Include available locations - include /etc/nginx/opennet/locations.conf; + include /etc/yggbro/nginx/opennet/locations.conf; } \ No newline at end of file