我的 nginx 设置有一点问题。我计划在一个网络中创建多个,其中一个中央服务器作为代理。
|---(/nextcloud/)--->Nextcloud-Server
-----> Central-Server--->|
|---(/git)---------->Git-Server
|
|---(/Redmine)---------->Redmine-Server
由于某种原因 URL 重定向无法正常工作,我使用 Nextcloud 服务器开始了此设置。我尝试使用几个重定向和重写规则,但无法正常工作。
访问某个位置时,我总是被重定向到中央服务器。所以 domain.net/nextcloud/ 将被重定向到 domain.net/login,但它实际上应该访问 domain.net/nextcloud/login。有人对此有解决方案吗?我当前的配置看起来像
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen 192.168.178.10:443 ssl;
server_name domain.net;
#root /usr/share/nginx/html;
ssl_certificate /mnt/docker/nginx/certs/fullchain.pem;
ssl_certificate_key /mnt/docker/nginx/certs/privkey.pem;
#include /etc/nginx/conf/ssl_params;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 15m;
ssl_session_tickets off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
#add_header Strict-Transport-Security "max-age=<HSTS_MAX_AGE>;<HSTS_SUBDOMAINS><HSTS_PRELOAD>";
client_max_body_size 10G;
location /n/ {
alias /usr/share/nginx/html/;
index index.html index.htm;
}
location /nextcloud/ {
access_log off;
proxy_set_header X-Real_ip $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://192.168.178.11/;
}
location ^~ /c{
rewrite ^/c(.*) /$1 break;
proxy_pass https://192.168.178.11/;
proxy_connect_timeout 1;
proxy_set_header Host $http_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 $https;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
}