2015-09-01 90 views
1

我已將ssl安裝到我的apache2併爲其端口443創建了https。當我試圖安裝ssl到Flask時,我無法讓它成功。這裏是我迄今爲止所做的事情。如何在不同端口的apache2/ubuntu14.04中的Flask上安裝ssl證書

我一直在使用/etc/apache2/sites-available/flask.conf

VirtualHost *:80> 
    ServerName example.com 
    ServerAdmin [email protected] 
    WSGIScriptAlias//var/www/FlaskApp/flaskapp.wsgi 
    <Directory /var/www/FlaskApp/FlaskApp/> 
     Order allow,deny 
     Allow from all 
    </Directory> 
    Alias /static /var/www/FlaskApp/FlaskApp/static 
    <Directory /var/www/FlaskApp/FlaskApp/static/> 
     Order allow,deny 
     Allow from all 
    </Directory> 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    LogLevel warn 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

<VirtualHost *:5000> 
    ServerName example.com 
    <Directory /var/www/FlaskApp/FlaskApp/> 
        Order allow,deny 
        Allow from all 
      </Directory> 


      SSLEngine on 
      SSLCertificateFile /etc/apache2/ssl/STAR_file.crt 
      SSLCertificateKeyFile /etc/apache2/ssl/STAR_file.key 
      SSLCertificateChainFile /etc/apache2/ssl/STAR_file_bundle.pem 
    <Location /> 
     SSLRequireSSL On 
     SSLVerifyClient optional 
     SSLVerifyDepth 1 
     SSLOptions +StdEnvVars +StrictRequire 
    </Location> 
    ErrorLog ${APACHE_LOG_DIR}/sslerror.log 
      LogLevel warn 
      CustomLog ${APACHE_LOG_DIR}/sslaccess.log combined 
    <FilesMatch "\.(cgi|shtml|phtml|php)$"> 
     SSLOptions +StdEnvVars 
    </FilesMatch> 
    <Directory /usr/lib/cgi-bin> 
    SSLOptions +StdEnvVars 
    </Directory> 

BrowserMatch "MSIE [2-6]" \ 
    nokeepalive ssl-unclean-shutdown \ 
    downgrade-1.0 force-response-1.0 
# MSIE 7 and newer should be able to use keepalive 
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown 
</VirtualHost>' 

的話,我也做了使example.com和重新啓動的Apache2

sudo的納米創建的文件,但是當我我在瀏覽器中檢查其端口5000不工作並且出錯爲
連接期間發生錯誤 SSL收到的記錄超出了允許的最大長度。 (錯誤代碼:ssl_error_rx_record_too_long)

回答

0

我建議將2個虛擬主機(端口80和端口5000)分隔到不同的虛擬主機文件,如/etc/apache2/sites-available/flask.conf和/ etc/apache2 /網站可用/瓶-ssl.conf中。我懷疑Apache會感到困惑,並且正在向HTTPS請求提供HTTP響應,這可能會導致該錯誤。如果您使用代理服務器,也可能有本地代理服務器配置錯誤。

我沒有注意到配置文件以外的任何錯誤。