安装HTTPS对本地主机通配符子域
我建立了我的本地的Ubuntu机 Laravel
应用程序。但我想用 HTTPS
在所有的外卡子域。我怎样才能做到这一点在当地?顺便说一句,我已经添加了我的网站的网址在 etc / hosts中
所以我并不需要键入本地主机
但而不是 www.mysite.loc
。
I have created a Laravel
application on my local Ubuntu machine. But I want to use HTTPS
on all of its wild card sub-domains. How can I do this locally? By the way, I have added my site URL on etc/hosts
so I don't need to type localhost
but instead www.mysite.loc
.
在回答这个问题的如何在Ubuntu上安装本地主机的SSL。 ?,我觉得只能在主域名。
Answer in this question How to install SSL on localhost in ubuntu..?, I think will only work on the main domain.
没有,这个问题的如何在本地主机在Ubuntu ..?工作正常安装SSL。但是,你需要修改code几行字在你的 CONF
文件。
No, the answer with this question How to install SSL on localhost in ubuntu..? is working fine. But you need to modify few lines of code in your conf
file.
我现在管理要尝试一下,工作正常,但我得到这个恼人的消息从我的网站,我访问不安全的浏览器。虽然这没关系,因为它仅仅是自签名证书。
I manage to try it now and works fine but I got this irritating message from my browser that the site I am accessing is not secure. Though it's okay, since it is just self signed certificate.
在我的 / etc / hosts中
我增加了我的本地站点的多个子领域,因为它不会工作,即使你正确地配置您的虚拟主机,因为该网站的发展是不但在线访问。
In my /etc/hosts
I added several sub domains for my local site since it will not work even you configured your virtual host properly because the site your developing is not yet accessible online.
说, www.mydomain.com
, hello.mydomain.com
,世界.mydomain.com
现在,我们需要启用SSL模块
Now, we need to enable SSL module
须藤a2enmod SSL
重启Apache
须藤服务的Apache2重启
创建一个文件夹的自签名SSL证书
Create a folder for Self-signed SSL Certificates
须藤的mkdir在/ etc / apache2的/ SSL
生成密钥和其他东西的SSL
Generate key and other stuffs for SSL
须藤OpenSSL的REQ -x509 -nodes -days 365 -newkey RSA:2048 -keyout /etc/apache2/ssl/apache.key退房手续/etc/apache2/ssl/apache.crt
回答问题的,并使用您的域名称 mydomain.com
为通用名称
Answer questions their and use your domain say mydomain.com
as Common name
现在我编辑了 CONF
我将驻留在 /etc/apache2/sites-available/mydomain.com.conf
Now I edited the conf
file of my virtual host which resides in /etc/apache2/sites-available/mydomain.com.conf
这是里面有什么
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin admin@example.com
ServerName www.mydomain.com
ServerAlias mydomain.com *.mydomain.com
DocumentRoot /home/me/projects/www/mysite_folder
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/home/me/projects/www/mysite_folder">
SSLOptions +StdEnvVars
Order allow,deny
Allow from all
# New directive needed in Apache 2.4.3:
Require all granted
AllowOverride All
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
如果您已经启用的虚拟主机,你需要跳过此步骤。否则,键入
If you already enable your virtual host, you need to skip this step. Else, type
须藤a2ensite mydomain.com.conf
最后,您需要再次重新启动Apache通过
Lastly, you need to restart Apache again by
须藤服务的Apache2重启
希望它可以帮助你!现在,您可以通过访问您的站点 HTTPS
Hope it helps you! You can now access your site using https
例。 https://www.mydomain.com
, https://hello.mydomain.com
, https://world.mydomain.com