2015-12-03 39 views
1

我刚刚用laravel伪造设置了3台服务器。 1个负载均衡器和2个包含我的laravel项目的文件服务器。Laravel Forge - 重定向循环 - SSL和负载均衡器

我已在所有三台服务器上安装了我的SSL证书,并将我的域指向负载平衡器服务器IP地址。

但是,现在访问我的网站网址时,我得到一个重定向循环。 任何人有任何建议?

下面是配置为负载平衡器(域问题删除):

server { 
    listen 80; 
    server_name mydomain.no; 
    return 301 https://mydomain.no$request_uri; 
} 

include upstreams/mydomain.no; 

server { 
    listen 443 ssl; 
    server_name .mydomain.no; 

    # FORGE SSL (DO NOT REMOVE!) 
    ssl_certificate /etc/nginx/ssl/mydomain.no/16768/server.crt; 
    ssl_certificate_key /etc/nginx/ssl/mydomain.no/16768/server.key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 

    charset utf-8; 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/mydomain.no-error.log error; 

    location/{ 
     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_set_header Host $http_host; 
     proxy_set_header X-NginX-Proxy true; 

     proxy_pass http://116816_app/; 
     proxy_redirect off; 

     # Handle Web Socket connections 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection "upgrade"; 
    } 
} 

这里是从我的文件服务器nginx的CONF:

server { 
    listen 80; 
    server_name mydomain.no; 
    return 301 https://mydomain.no$request_uri; 
} 

server { 
    listen 443 ssl; 
    server_name .mydomain.no; 
    root /home/forge/mydomain.no/httpdocs/public; 

    # FORGE SSL (DO NOT REMOVE!) 
    ssl_certificate /etc/nginx/ssl/mydomain.no/16782/server.crt; 
    ssl_certificate_key /etc/nginx/ssl/mydomain.no/16782/server.key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 

    index index.html index.htm index.php; 

    charset utf-8; 

    location/{ 
     try_files $uri $uri/ /index.php?$query_string; 
    } 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/mydomain.no-error.log error; 

    error_page 404 /index.php; 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

server { 
    listen 80; 
    server_name mydomain.no; 
    return 301 https://mydomain.no$request_uri; 
} 

server { 
    listen 443 ssl; 
    server_name .mydomain.no; 
    root /home/forge/mydomain.no/httpdocs/public; 

    # FORGE SSL (DO NOT REMOVE!) 
    ssl_certificate /etc/nginx/ssl/mydomain.no/16783/server.crt; 
    ssl_certificate_key /etc/nginx/ssl/mydomain.no/16783/server.key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 

    index index.html index.htm index.php; 

    charset utf-8; 

    location/{ 
     try_files $uri $uri/ /index.php?$query_string; 
    } 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/mydomain.no-error.log error; 

    error_page 404 /index.php; 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

回答

0

您正在连接到您的上游使用http方案。这导致它重定向到https,然后负载平衡器使用http向上游路由。因此,循环。

可以连接上游使用https

proxy_pass https://116816_app/; 

或者让你的上游文件服务器使用http接受连接:

server { 
    listen 80; 
    listen 443 ssl; 
    ... 
}