简体   繁体   English

本地开发服务器上的ssl

[英]ssl on a local dev server

I am running ubuntu as a testing server on my laptop. 我在笔记本电脑上将ubuntu作为测试服务器运行。 I am attempting to set up some of the test sites with self signed ssl certificates. 我正在尝试使用自签名的ssl证书设置一些测试站点。 I think I have everything correct except perhaps the apache 2 conf files. 我认为除了apache 2 conf文件之外,我一切都正确。

When creating the cerificates I gave the common name as *.hr4.mdev. 创建证书时,我的通用名称为* .hr4.mdev。 "mdev" is what I have arbitrarily called my local dev environment. 我随意将“ mdev”称为本地开发环境。

So I modified my existing conf file to listen on 443 instead on 80 (line 1) and I added lines 6, 7 and 8. 因此,我修改了现有的conf文件,以监听443而不是监听80(第1行),并添加了第6、7和8行。

<VirtualHost *:443>
  ServerAdmin  myemail@mydomain.com
  ServerName   marino.hr4.mdev
  ServerAlias  *.marino.hr4.mdev
  DocumentRoot /var/www/marino.hr4/htdocs
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/apache.crt
  SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  <Directory /var/www/marino.hr4/htdocs>
    php_value include_path /var/www/marino.hr4/htdocs
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/www/marino.hr4/logs/error.log
  # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
  LogLevel debug

  CustomLog /var/www/marino.hr4/logs/access.log combined
</VirtualHost>

Now when I go to the site ( https://marino.hr4.mdev ) I am advised that "It works!" 现在,当我转到该站点( https://marino.hr4.mdev )时,系统提示“它有效!” Which is reassuring on a certain level, but it is not the content that I expected to see. 在一定程度上可以放心,但这不是我期望看到的内容。


Having referenced tremor's link, my conf file now looks like this: 引用了tremor的链接后,我的conf文件现在看起来像这样:

<VirtualHost 192.168.73.128:443>
  SSLEngine on
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP

  SSLCertificateFile /etc/apache2/ssl/apache.crt
  SSLCertificateKeyFile /etc/apache2/ssl/apache.key

  ServerAdmin  bernard@theminery.com
  ServerName   marino.hr4.mdev
  ServerAlias  *.marino.hr4.mdev
  DocumentRoot /var/www/marino.hr4/htdocs

  <Directory /var/www/marino.hr4/htdocs>
    php_value include_path /var/www/marino.hr4/htdocs
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/www/marino.hr4/logs/error.log
  # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
  LogLevel debug

  CustomLog /var/www/marino.hr4/logs/access.log combined
</VirtualHost>

after restarting Apache I am asked to add a security exception, which is fine, but I am then kicked to another site I have set up on my machine. 重新启动Apache之后,系统要求我添加一个安全例外,这很好,但是随后又被踢到了我在计算机上设置的另一个站点。

Add NameVirtualHost directive, something like this perhaps? 添加NameVirtualHost指令,也许像这样?

NameVirtualHost *:443
Listen 443

Your apache server is obviously serving up it's default server "It works" instead of your website. 您的apache服务器显然正在为其默认服务器“有效”服务,而不是您的网站。

Here is some supporting information from apache: http://wiki.apache.org/httpd/NameBasedSSLVHosts 以下是来自Apache的一些支持信息: http : //wiki.apache.org/httpd/NameBasedSSLVHosts

Edit: 编辑:

Potentially move your virtual host to the first referenced vhost in the conf file, default is selected based on order. 可能将您的虚拟主机移动到conf文件中第一个引用的虚拟主机,默认情况是根据顺序选择的。

So in the end I modified the ports.conf file and added 443 to the Listen directive, so now it reads: 因此,最后我修改了ports.conf文件,并将443添加到Listen指令中,现在它显示为:

Listen 80 443
<IfModule ssl_module>
  Listen 443
</IfModule>
<IfModule mod_gnutls.c>
  listen 443
</IfModule>

I also changed the first line of my conf file from 我也将conf文件的第一行从

<VirtualHost 192.168.73.128:443>

back to 回到

<VirtualHost *:443>

Special thanks to tremor for pointing me in the right direction. 特别感谢震颤指向我正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM