2015-04-22 162 views
0

請幫助我:這virtual.conf nginx conf文件中有什麼問題,這意味着在查看網站時,我得到錯誤ssl_error_rx_record_too_long,而不是能夠查看我的網站。我正在使用aws,nginx來爲一些rails應用程序提供服務 - 昨天工作正常,但是我崩潰了整個服務器,並且瘋狂地試圖在凌晨2點解決這個問題,並準備在上午9:30進行生產。通過nginx服務ssl網頁,ssl_error_rx_record_too_long

ssl_certificate  /etc/ssl/star_my_site.pem; 
ssl_certificate_key   /etc/ssl/star_my_site.key; 


# ------------------ 
# rails app one 
# ------------------ 

upstream my_app { 
    server unix:///var/run/puma/my_app.sock; 
} 

server { 
    listen  80; 
# server_name rails_app_one.my_site.com.au www.rails_app_one.my_site.com.au; 
    server_name _ localhost; 
    return  301 https://rails_app_one.my_site.com.au; 
} 

server { 
    listen 443; 
    server_name _ localhost; 

    location/{ 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto https; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://my_app; 
    } 

    location ~ "^/assets/" { 
    root /var/app/current/public; 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    } 
} 

# ------------------ 
# rails app two 
# ------------------ 

upstream rails_app_two_app { 
    server unix:///var/run/puma/rails_app_two_app.sock; 
} 

server { 
    listen  80; 
    server_name rails_app_two.my_site.com.au www.rails_app_two.my_site.com.au; 
    return  301 https://rails_app_two.my_site.com.au; 
} 

server { 
    listen 443; 
    server_name rails_app_two.my_site.com.au; 

    location/{ 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto https; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://rails_app_two_app; 
    } 

    location ~ "^/assets/" { 
    root /var/app/rails_app_two.my_site.com.au/current/public; 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    } 
} 

回答

0

ssl_error_rx_record_too_long通常意味着當瀏覽器正期待HTTPS內容的服務器返回普通HTTP內容。 (您可以通過轉到http://your.site:443並查看您的網站來驗證此問題。)

您需要在nginx中啓用SSL - 僅僅聲明ssl_certificate是不夠的。

變化listen 443;listen 443 ssl;

(另外,我建議把ssl_certificate在服務器塊,這樣你就可以使用不同的SSL證書與其他域)

編輯:https://serverfault.com/questions/497430/error-code-ssl-error-rx-record-too-long具有幾乎相同問題,希望你在9am產品發佈前找到它!