[英]How to install ssl certificate on Flask in apache2/ubuntu14.04 with different ports
i have installed ssl to my apache2 and created https for port of 443, its working. 我已经将ssl安装到我的apache2中,并为443端口创建了https,它可以正常工作。 when i tried to install ssl to Flask i could not make it as successful.
当我尝试将ssl安装到Flask时,我无法使其成功。 here are things i have done so far.
这是我到目前为止所做的事情。
i have created file using sudo nano /etc/apache2/sites-available/flask.conf 我已经使用sudo nano /etc/apache2/sites-available/flask.conf创建了文件
VirtualHost *:80>
ServerName example.com
ServerAdmin admin@example.com
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>'
then i have done the enable example.com and restarted the apache2 然后我完成了启用example.com并重新启动了apache2
but when i am check in browser its not working for the port 5000 and get error as 但是当我在浏览器中签入时,它不能用于端口5000并得到如下错误
An error occurred during a connection SSL received a record that exceeded the maximum permissible length. 连接SSL期间收到的记录超出最大允许长度时发生错误。 (Error code: ssl_error_rx_record_too_long)
(错误代码:ssl_error_rx_record_too_long)
I suggest separating the 2 virtual hosts (port 80 and port 5000) to different virtual host files, such as /etc/apache2/sites-available/flask.conf and /etc/apache2/sites-available/flask-ssl.conf. 我建议将2个虚拟主机(端口80和端口5000)分离到不同的虚拟主机文件,例如/etc/apache2/sites-available/flask.conf和/etc/apache2/sites-available/flask-ssl.conf。 I suspect apache is confused and is serving an HTTP response to an HTTPS request, which can cause that error.
我怀疑apache感到困惑,并且正在为HTTPS请求提供HTTP响应,这可能会导致该错误。 It is also possible that you might have a local proxy that's misconfigured, if you use a proxy.
如果使用代理,则也可能是本地代理配置错误。
I didn't notice anything wrong with the config file other than that. 除此以外,我没有发现配置文件有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.