2017-04-12 1 views
0

J'ai un petit problème concernant ma configuration de nginx. Je prévois de créer plusieurs dans un réseau avec un serveur central en tant que proxy. J'ai commencé cette configuration avec mon serveur Nextcloud pour une raison quelconque. Les redirections d'URL ne fonctionnent pas correctement. J'ai essayé d'utiliser plusieurs règles de redirection et de réécriture, mais je n'ai pas réussi à le faire fonctionner.NGNIX Backward Proxy pour une erreur de redirection d'URL Nextcloud

Lorsque j'accède à un emplacement, je suis toujours redirigé vers le serveur central. Donc, domain.net/nextcloud/ sera redirigé vers domain.net/login, mais il devrait effectivement accéder à domain.net/nextcloud/login. Quelqu'un at-il une solution pour cela? Ma config actuelle ressemble

# 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; 
} 

} 
} 
+0

J'utilise cette configuration pourrait pourrait aider: https://github.com/evertramos/docker-compose-letsencrypt- nginx-proxy-companion avec https://github.com/evertramos/docker-nextcloud-letsencrypt – Evis

Répondre

-1
upstream nextcloud { 
    server 127.0.0.1:8209 
} 

server { 

    listen 443 ssl; 

    server_name www.abc.xyz; 

    ssl_certificate server.crt; 
    ssl_certificate_key server.key; 
    ssl_client_certificate ca.crt; 


    add_header X-Content-Type-Options nosniff; 
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Robots-Tag none; 
    add_header X-Download-Options noopen; 
    add_header X-Permitted-Cross-Domain-Policies none; 


    location = /robots.txt { 
     allow all; 
     log_not_found off; 
     access_log off; 
    } 


    rewrite ^/core/(.+?)$ /nextcloud/core/$1 last; 
    rewrite ^/apps/(.+?)$ /nextcloud/apps/$1 last; 
    rewrite ^/js/(.+?)$ /nextcloud/js/$1 last; 
    rewrite ^/css/(.+?)$ /nextcloud/css/$1 last; 
    rewrite ^/ocs/(.+?)$ /nextcloud/ocs/$1 last; 
    rewrite ^/settings/(.+?)$ /nextcloud/settings/$1 last; 
    rewrite ^/remote.php/(.+?)$ /nextcloud/remote.php/$1 last; 

    rewrite ^/login(.*)$ /nextcloud/login$1 last; 
    rewrite ^/lostpassword(.*)$ /nextcloud/lostpassword$1 last; 

    location /nextcloud { 
     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_pass   http://nextcloud/; 
     proxy_read_timeout 90; 

     proxy_redirect  https://www.abc.xyz https://www.abc.xyz/nextcloud; 
    } 
} 

Juste pour nuage prochain, quel serveur git-vous choisi?

gitlab-ce supply relative url 

https://docs.gitlab.com/omnibus/settings/nginx.html

external_url "https://gitlab.example.com" -> "https://gitlab.example.com/git"