2023-03-31 08:36:53 +08:00
|
|
|
# ------------------------------------------------------------
|
|
|
|
# domain.com
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
|
2023-09-19 15:55:26 +08:00
|
|
|
server_name ~\.?[0-9a-zA-Z]$;
|
2023-03-31 08:36:53 +08:00
|
|
|
|
2023-07-19 11:13:52 +08:00
|
|
|
access_log /data/logs/proxy-host-1_access.log proxy;
|
|
|
|
error_log /data/logs/proxy-host-1_error.log warn;
|
2023-03-31 08:36:53 +08:00
|
|
|
|
2023-09-20 09:53:00 +08:00
|
|
|
if ($http_referer ~* /w9deployment/) {
|
|
|
|
rewrite ^/locales/(.*) /w9deployment/locales/$1 break;
|
2023-03-31 08:36:53 +08:00
|
|
|
}
|
2023-07-19 11:13:52 +08:00
|
|
|
|
2023-09-18 17:13:15 +08:00
|
|
|
location / {
|
|
|
|
# Proxy!
|
|
|
|
include conf.d/include/proxy.conf;
|
2023-09-20 09:53:00 +08:00
|
|
|
}
|
2023-09-18 17:13:15 +08:00
|
|
|
|
|
|
|
# proxy for portainer
|
|
|
|
location /w9deployment/ {
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-Scheme $scheme;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header Accept-Encoding \"\";
|
|
|
|
proxy_pass http://websoft9-deployment:9000/;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection $http_connection;
|
2023-10-12 13:47:38 +08:00
|
|
|
# proxy_http_version 1.1;
|
|
|
|
add_header 'Access-Control-Allow-Origin' $http_origin;
|
2023-09-18 17:13:15 +08:00
|
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
|
|
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
|
|
|
|
if ($request_method = OPTIONS) {
|
|
|
|
return 204;
|
|
|
|
}
|
2024-04-10 11:35:18 +08:00
|
|
|
# set $quot_tmp "\"";
|
|
|
|
# set $portainer_jwt "${quot_tmp}${cookie_portainerJWT}${quot_tmp}";
|
|
|
|
# sub_filter '</head>' "<script>($portainer_jwt)?window.localStorage.setItem('portainer.JWT', '$portainer_jwt'):null;</script></head>";
|
|
|
|
# sub_filter_once on;
|
|
|
|
# sub_filter_types *;
|
2023-09-18 17:13:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# proxy for Nginx proxy Manager
|
|
|
|
location /w9proxy/ {
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-Scheme $scheme;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_pass http://websoft9-proxy:81;
|
|
|
|
rewrite ^/w9proxy/?(.*)$ /$1 break;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_redirect off;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_cache_bypass $http_upgrade;
|
|
|
|
proxy_set_header Connection $http_connection;
|
|
|
|
proxy_cache_bypass $http_secret_header;
|
|
|
|
proxy_set_header Accept-Encoding \"\";
|
|
|
|
add_header Pragma "no-cache";
|
|
|
|
add_header Cache-Control "no-cache";
|
|
|
|
if ($request_method = OPTIONS) {
|
|
|
|
return 204;
|
|
|
|
}
|
|
|
|
sub_filter '</head>' "<script>var tokens='$cookie_nginx_tokens';(tokens)?window.localStorage.setItem('nginx-proxy-manager-tokens', '[{\"t\":\"$cookie_nginx_tokens\",\"n\":\"$cookie_nginx_nikeName\"}]'):null;</script></head>";
|
|
|
|
# source changes
|
|
|
|
sub_filter 'href="/' 'href="/w9proxy/';
|
|
|
|
sub_filter 'src="/' 'src="/w9proxy/';
|
|
|
|
sub_filter '/api' '/w9proxy/api';
|
|
|
|
sub_filter '/assets' '/w9proxy/assets';
|
|
|
|
sub_filter '/js/' '/w9proxy/js/';
|
|
|
|
# script changes
|
|
|
|
sub_filter 'r.p="/' 'r.p="/w9proxy/';
|
|
|
|
sub_filter '"/login' '"/w9proxy/login';
|
|
|
|
sub_filter 'case"/logout"' 'case"/w9proxy/logout"';
|
|
|
|
sub_filter 'window.location="/"' 'window.location="/w9proxy/"';
|
|
|
|
sub_filter 'history.start({pushState:!0})' 'history.start({pushState:!0,root: "/w9proxy/"})';
|
|
|
|
sub_filter 'i.history.navigate(e.' 'i.history.navigate(e.replace("/w9proxy","").';
|
|
|
|
sub_filter_types *;
|
|
|
|
sub_filter_once off;
|
|
|
|
}
|
|
|
|
|
|
|
|
# proxy for Gitea
|
|
|
|
location /w9git/ {
|
|
|
|
proxy_pass http://websoft9-git:3000/;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_hide_header X-Frame-Options;
|
2023-10-12 13:47:38 +08:00
|
|
|
add_header 'Access-Control-Allow-Origin' $http_origin;
|
2023-09-18 17:13:15 +08:00
|
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
2024-10-09 08:50:28 +08:00
|
|
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-xsrf-token';
|
2023-10-12 13:47:38 +08:00
|
|
|
add_header 'Access-Control-Allow-Credentials' 'true';
|
2023-09-18 17:13:15 +08:00
|
|
|
if ($request_method = OPTIONS) {
|
|
|
|
return 204;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-07 11:43:43 +08:00
|
|
|
location /api/ {
|
2024-03-13 08:39:02 +08:00
|
|
|
proxy_pass http://websoft9-apphub:8080;
|
2023-10-26 16:37:36 +08:00
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2023-11-07 11:43:43 +08:00
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
2023-11-07 16:41:48 +08:00
|
|
|
add_header 'Access-Control-Allow-Origin' $http_origin always;
|
|
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
|
|
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-api-key' always;
|
2023-11-07 11:43:43 +08:00
|
|
|
if ($request_method = OPTIONS) {
|
|
|
|
return 204;
|
|
|
|
}
|
|
|
|
}
|
2023-05-25 09:09:42 +08:00
|
|
|
|
2023-10-23 16:25:27 +08:00
|
|
|
location /media/ {
|
|
|
|
proxy_pass http://websoft9-apphub:8081/images/;
|
|
|
|
}
|
|
|
|
|
2023-03-31 08:36:53 +08:00
|
|
|
# Custom
|
|
|
|
include /data/nginx/custom/server_proxy[.]conf;
|
2023-10-12 13:47:38 +08:00
|
|
|
}
|