2015-01-20 11 views
5

Tüm http trafiğini https'ye bir dizi özel durumla yeniden yönlendirmek istiyorum. URL'de/istisna/ile ilgili herhangi bir şey http tutmak istiyorum. nginx istisnalar hariç tüm http'ları https olarak yeniden yönlendiriyor

Redirect all http to https in nginx, except one file

önerdiği aşağıdaki fakat işe yaramıyor denediniz./Exception/urls, bir laravel çerçevesindeki bazı php işlemleri için nginx'ten apache'ye aktarılacak, ancak bu önemli olmamalı.

Gelişim için herhangi bir öneri çok takdir!

server { 
    listen 127.0.0.1:80; 

    location/{ 
     proxy_pass http://127.0.0.1:7080; 
     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-Accel-Internal /internal-nginx-static-location; 
     access_log off; 
    } 

    location /exception/ { 
     # empty block do nothing 
     # I've also tried adding "break;" here 
    } 

    return 301 https://localhost$request_uri; 
} 

cevap

5

Nginx en uzun eşleştirme yerini bulur ve ilk bunu işler, ancak sunucu blok sonunda dönüş olursa olsun işlenirken. Bu, her şeyden önce/istisnayı yönlendirir.

server { 
    listen 127.0.0.1:80; 
    access_log off; 

    location/{ 
     return 301 https://localhost$request_uri; 
    } 

    location /exception/ { 
     proxy_pass http://127.0.0.1:7080; 
     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-Accel-Internal /internal-nginx-static-location; 
    }  
} 
+0

Harika çalıştı, teşekkürler! – mba12