Same server, both SSL and non-SSL

半腔热情 提交于 2019-12-03 15:22:41

问题


Is it possible to have both SSL protocol and non-SSL protocol running on the same server in Apache 2.x?

So if I access http://example.com (non-SSL) and https://example.com (SSL) they would both be available.

If so, would I need to create a virtual host? How would this VirtualHost directive look like, could anyone give me an example? (Assuming I already have the certificates)


回答1:


Yes, you simply add another VirtualHost for the same name on port 443 (HTTPS). Set SSLProtocol to whichever protocols you wish to allow.

<VirtualHost *:80>
    ServerName your-domain.com
    DocumentRoot /var/www/your-domain-root
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/your-domain-root
    ServerName your-domain.com
    SSLEngine On
    SSLOptions +StrictRequire
    SSLCertificateFile /path/to/server.crt
    SSLCertificateKeyFile /path/to/server.key
    SSLProtocol TLSv1
</VirtualHost>


来源:https://stackoverflow.com/questions/9126851/same-server-both-ssl-and-non-ssl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!