如何在ownCloud中使用HTTPS和DHCP?
系统:Ubuntu 14.04服务器,Apache 2.4,ownCloud 8.2.5,测试环境Raspbian Jessie on Raspberry Pi 3 b。 访问https://192.168.1.107
和https://192.168.1.107
时,服务器的Internet浏览器中有关HTTPS的错误
Error performing TLS handshake: An unexpected TLS packet was received.
调试
- 命令
telnet 192.168.1.107 80
只是挂起来用于HTTP,类似于telnet 192.168.1.107 443
用于HTTPS。 - 在互联网浏览器中访问
http://192.168.1.107
和http://192.168.1.107/owncloud
时访问HTTP,但不像以前那样通过telnet
- 日志
/var/log/apache2/error.log
没有最近的错误。/var/log/apache2/access.log
没有错误,而没有/var/log/apache2/other_vhosts_access.log
。
sudo apache2ctl -M |sort
的输出是
access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) core_module (static) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) headers_module (shared) http_module (static) Loaded Modules: log_config_module (static) logio_module (static) mime_module (shared) mpm_prefork_module (shared) negotiation_module (shared) php5_module (shared) rewrite_module (shared) setenvif_module (shared) socache_shmcb_module (shared) so_module (static) ssl_module (shared) status_module (shared) unixd_module (static) version_module (static) watchdog_module (static)
我的设置应与约翰的设置大致相同
-
/etc/apache2/sites-available/
000-default.conf
和000-default-ssl.conf
。 -
/etc/apache2/sites-enabled/
:ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf
和ln -s /etc/apache2/sites-available/000-default-ssl.conf
。 -
/etc/apache2/conf-available/
owncloud.conf
-
/etc/apache2/conf-enabled/
:ln -s /etc/apache2/conf-available/owncloud.conf /etc/apache2/conf-enabled/owncloud.conf
和其他符号链接。 -
error-ssl.log
和access-ssl.log
用于不将它们与sites-available/000-default-ssl.conf
标准日志混合使用。
我的ssl
证书和密钥位于/etc/ssl/
。 我的/etc/apache2/sites-enabled/000-default.conf
我在这里跟踪了这个post
SSLEngine on SSLCertificateFile /etc/ssl/apache.crt SSLCertificateKeyFile /etc/ssl/apache.key
我唯一的区别是我没有这些行SSLCertificateChainFile /etc/ssl/subca.crt; SSLCACertificateFile /etc/ssl/ca.crt
SSLCertificateChainFile /etc/ssl/subca.crt; SSLCACertificateFile /etc/ssl/ca.crt
因为我不应该有ChainFile。 文件/var/www/owncloud/config/config.php
是
'yours', 'passwordsalt' => 'yours', 'secret' => 'yours', 'trusted_domains' => array ( 0 => '192.168.1.107', 1 => '192.168.1.1', 2 => 'localhost', ), 'datadirectory' => '/var/www/owncloud/data', 'overwrite.cli.url' => '192.168.1.107/owncloud', 'dbtype' => 'sqlite3', 'version' => '8.2.5.2', 'logtimezone' => 'UTC', 'installed' => true, 'memcache.local' => '\\OC\\Memcache\\APCu', 'theme' => '', 'loglevel' => 2, 'maintenance' => false, 'trashbin_retention_obligation' => 'auto', 'mail_from_address' => 'masimasi', 'mail_smtpmode' => 'sendmail', 'mail_domain' => 'gmail.com', 'mail_smtpauthtype' => 'LOGIN', 'mail_smtphost' => 'smtp.gmail.com', 'mail_smtpport' => '587', );
/etc/apache2/sites-available/000-default-ssl.conf
是
ServerAdmin webmaster@localhost ServerName localhost DocumentRoot /var/www/html ErrorLog /var/log/apache2/error.log CustomLog /var/log/apache2/access.log combined SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIU SSLCertificateFile /etc/ssl/apache.crt SSLCertificateKeyFile /etc/ssl/apache.key SetEnvIf User-Agent .*MSIE.* nokeepalive ssl-unclean-shutdown CustomLog /var/log/apache2/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" SSLOptions +StdEnvVars SSLOptions +StdEnvVars
权限/所有者644/root:root
应该是关于SSL的
ls -ls /etc/apache2/ssl/ total 8 4 -rw-r--r-- 1 root root 1484 May 31 15:17 apache.crt 4 -rw-r--r-- 1 root root 1704 May 31 15:17 apache.key
sites-x
中的设置,其中有两个符号链接
ls -la /etc/apache2/sites-available/ total 16 drwxr-xr-x 2 root root 4096 May 31 21:52 . drwxr-xr-x 9 root root 4096 May 31 15:44 .. -rw-r--r-- 1 root root 183 May 31 19:43 000-default.conf -rw-r--r-- 1 root root 916 May 31 21:50 000-default-ssl.conf ls -la /etc/apache2/sites-enabled/ total 8 drwxr-xr-x 2 root root 4096 May 31 19:38 . drwxr-xr-x 9 root root 4096 May 31 15:44 .. lrwxrwxrwx 1 root root 45 May 31 19:35 000-default.conf -> /etc/apache2/sites-available/000-default.conf lrwxrwxrwx 1 root root 35 May 31 11:50 000-default-ssl.conf -> ../sites-available/000-default.conf
conf-x
中的设置,其中包含7个符号链接
ls -la /etc/apache2/conf-available/ total 40 drwxr-xr-x 2 root root 4096 May 31 20:07 . drwxr-xr-x 9 root root 4096 May 31 15:44 .. -rw-r--r-- 1 root root 315 Oct 24 2015 charset.conf -rw-r--r-- 1 root root 127 Jul 29 2013 javascript-common.conf -rw-r--r-- 1 root root 3224 Oct 24 2015 localized-error-pages.conf -rw-r--r-- 1 root root 189 Oct 24 2015 other-vhosts-access-log.conf -rw-r--r-- 1 root root 410 May 31 19:11 owncloud.conf -rw-r--r-- 1 root root 655 Feb 19 2015 phppgadmin.conf -rw-r--r-- 1 root root 2190 Nov 28 2015 security.conf -rw-r--r-- 1 root root 455 Oct 24 2015 serve-cgi-bin.conf ls -la /etc/apache2/conf-enabled/ total 8 drwxr-xr-x 2 root root 4096 May 31 13:45 . drwxr-xr-x 9 root root 4096 May 31 15:44 .. lrwxrwxrwx 1 root root 30 May 31 11:50 charset.conf -> ../conf-available/charset.conf lrwxrwxrwx 1 root root 44 May 31 11:50 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf lrwxrwxrwx 1 root root 46 May 31 11:50 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf lrwxrwxrwx 1 root root 31 May 31 13:45 owncloud.conf -> ../conf-available/owncloud.conf lrwxrwxrwx 1 root root 33 May 31 12:03 phppgadmin.conf -> ../conf-available/phppgadmin.conf lrwxrwxrwx 1 root root 31 May 31 11:50 security.conf -> ../conf-available/security.conf lrwxrwxrwx 1 root root 36 May 31 11:50 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
JohnOrion关于这个问题的假设 :
您可以尝试自己设置静态IP地址并正确设置网络,这样您就可以在服务器计算机上的浏览器中键入localhost,它应该转到该站点..如果它不…那可能是个问题..如果ssl正在寻找localhost但它无法找到它因为某种原因你的网络没有显示localhost指向你的本地IP ..这是冷的原因。
我对这个问题的假设 。 输出命令curl --head localhost | grep Server
curl --head localhost | grep Server
是Server: Apache/2.4.10
,其中没有任何说明SSL模块正确加载。 我认为在某些情况下应该这样做。 不确定。
制作SSL密钥/ crt
关于做.key和.crt的线程 。
问题不在于它是自签名证书,但通用名称必须包含子域。 我只使用通用名domain.com签署了证书,但我的owncloud正在cloud.domain.com中运行
然而, 这里关于localhost所以commonname应该只有192.168.1.107
没有尾部斜杠,这在我的系统中现在是正确的。
你如何为localhost签署自我证书? 我在公共名称中包含192.168.1.107/owncloud
但不确定它是否正确。
如何在ownCloud中使用带有DHCP的自签名HTTPS?
它可能会失败,因为您尚未为https配置服务器。 https的Apache配置要求您侦听端口443以及端口80,并使用证书为TLS配置服务器。
(来自apache文档的示例)
LoadModule ssl_module modules/mod_ssl.so Listen 443 ServerName www.example.com SSLEngine on SSLCertificateFile "/path/to/www.example.com.cert" SSLCertificateKeyFile "/path/to/www.example.com.key"
用于配置HTTPS的Ubuntu文档
由于您似乎没有启用完整的网站,也许这就是为什么您无法让重定向工作。 我试图重新创建这个问题..我发现的第一个问题是重定向没有添加/
我提到的。 由于这没有解决问题,我还使用重写function强制owncloud转到https。 这就是我管理的方式:
转到owncloud目录/var/www/owncloud
并打开.htaccess文件。
向下滚动到底部附近,您将看到#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####
行之前的任何内容#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####
在下面添加以下行:
RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
所以看起来应该是这样的
Options -Indexes ModPagespeed Off #### DO NOT CHANGE ANYTHING ABOVE THIS LINE #### #### Part you need to add ##### RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] #### end of part you need to add #### ErrorDocument 403 /owncloud/core/templates/403.php ErrorDocument 404 /owncloud/core/templates/404.php RewriteRule . index.php [PT,E=PAT
这应该使用重写规则强制owncloud在https下运行