分类 云计算 下的文章

在 wdcp v3 面板上,为站点启用SSL证书,实现https访问

云友“qq2694067 ”,想知道在wdcp v3里如何实现https访问,所以写此帖。

环境:CentOS 7

1.安装 wdCP v3.0.8,选择 apache web
bbs-aliyun-dongshan3-308008-1.png

2.创建 yun.anqun.org 站点

3.将站点的SSL证书上传到相应的目录,如本例的 yun_anqun_org.pem 上传到了 /etc/pki/tls/certs/ 目录,yun_anqun_org.key 上传到了 /etc/pki/tls/private/ 目录,需要留意,key文件仅root账户可读写

4.通过“文件管理器”里,编辑 /www/wdlinux/apache/conf/httpd.conf 文件内容,启用 mod_ssl.so,即
LoadModule ssl_module modules/mod_ssl.so
bbs-aliyun-dongshan3-308008-2.png

5.通过“文件管理器”里,编辑 /www/wdlinux/apache/conf/httpd.conf 文件内容,增加SSL相关内容设置,

Listen 443
<VirtualHost *:443>
      ServerName yun.anqun.org
      DocumentRoot     /www/web/yun_anqun_org/public_html
      SSLEngine on
      SSLProtocol all -SSLv2
      SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
      SSLCertificateFile "/etc/pki/tls/certs/213949634960268.pem"
      SSLCertificateKeyFile "/etc/pki/tls/private/213949634960268.key"
</VirtualHost>

bbs-aliyun-dongshan3-308008-3.png

6.在“安全管理”,防火墙(iptables)里添加443端口,允许访问
bbs-aliyun-dongshan3-308008-4.png

bbs-aliyun-dongshan3-308008-5.png

7.重启httpd服务后,在火狐浏览器里测试,https正常访问
bbs-aliyun-dongshan3-308008-6.png

为“阿里云linux一键安装web环境”(apache)站点布置SSL访问

应云友“湫兮如风 ”要求,写一个例子,内容是如何在“阿里云linux一键安装web环境”中的apache站点布置SSL访问。

环境:CentOS 7.2,“阿里云linux一键安装web环境”安装包(sh-1.5.5),apache

过程:

1.使用 sh-1.5.5 安装脚本,完成 apache 2.4 + php5.5 + mysql5.6 的环境安装
bbs-aliyun-dongshan3-307285-1.png

bbs-aliyun-dongshan3-307285-2.png

2.将从阿里云安全证书下载的证书文件 213949634960268.pem 上传到 /etc/pki/tls/certs ,213949634960268.key 上传到 /etc/pki/tls/private ,请注意 key 文件仅root用户可读写

修改 apache 的配置文件, /alidata/server/httpd/conf/httpd.conf ,启用引用配置文件 conf/extra/httpd-ssl.conf 和 两个模块:mod_ssl.so, mod_socache_shmcb.so

bbs-aliyun-dongshan3-307285-3.png

bbs-aliyun-dongshan3-307285-4.png

bbs-aliyun-dongshan3-307285-5.png

3.修改 httpd-ssl.conf 的站点配置内容,如本例,删除原有的 VirtualHost 内容,用以下内容替换:

##
## SSL Virtual Host Context
##
<VirtualHost *:443>
  ServerName yun.anqun.org
  DocumentRoot /alidata/www/wordpress
  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
  SSLCertificateFile "/etc/pki/tls/certs/213949634960268.pem"
  SSLCertificateKeyFile "/etc/pki/tls/private/213949634960268.key"
</VirtualHost>

bbs-aliyun-dongshan3-307285-6.png

4.下载wordpress程序文件,解压到 /alidata/www 目录中,更改wordpress目录的属性为 www 用户

5.重启apache服务
systemctl restart httpd

6.在浏览器访问ssl站点,https://yun.anqun.org ,测试正常
bbs-aliyun-dongshan3-307285-7.png

参考:https://market.aliyun.com/products/53690006/cmgj000262.html?spm=5176.bbsr307238.0.0.VCiCd4#sku=biaozhunban

nodeJS使用阿里云免费SSL证书简例

云友“ leonkwok1992 ”在问答里想知道在nodeJS里怎么实现https访问,所以写此帖。

环境:Debian 8,阿里云公共镜像。

步骤:

1.安装 nodejs
apt-get install nodejs
bbs-aliyun-dongshan3-306848-1.png

2.编辑 web.js 文件,内容如下:

var https = require('https');
var fs = require('fs');
var options = {
  key: fs.readFileSync('213949634960268.key'),
  cert: fs.readFileSync('213949634960268.pem')
};
var a = https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(443);

bbs-aliyun-dongshan3-306848-2.png

3.将从阿里云证书服务下载的文件,213949634960268.key 和 213949634960268.pem 上传到与 web.js 同一个路径中

4.运行(本例以root身份运行,图简单)
nodejs web.js
bbs-aliyun-dongshan3-306848-3.png

5.在火狐浏览器访问测试,https内容显示正常
bbs-aliyun-dongshan3-306848-4.png

参考:

在Debian 8 系统里安装python3

云友“seiya0613 ”在云栖里问怎么在Debian 8里安装python3,所以写此帖。

环境:阿里云公共镜像,debian 8 64位

过程:

1.默认,运行的python版本是2.7
bbs-aliyun-dongshan3-306726-1.png

2.安装python3
apt-get install python3
bbs-aliyun-dongshan3-306726-2.png

3.即使安装了python3,默认还是使用python2

4.使用 update-alternatives 来管理python的使用版本
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2

  1. 现在运行python,默认是使用3.4版本了
    python --version
    bbs-aliyun-dongshan3-306726-3.png

参考:

在Debian 8 系统里设置apache web的虚拟主机

云友“bokie ”提到,不想让他人的域名访问到自己ECS服务器上的站点内容。

因为安装Apache后,在浏览器地址栏里输入ECS的公网地址,访问到的页面是默认站点的内容,如果这时有他人的域名解析到这个公网IP地址,也会访问到相同的内容。

本例环境:Debian 8,通过apt-get安装了apache web,yun.anqun.org 和 portal.anqun.org 两个域名均解析到了ECS的公网IP地址:121.43.110.72

过程:

1.打开apache的虚拟主机配置文件目录,/etc/apache2/sites-enabled ,里边有一个默认站点的配置文件,000-default.conf,内容如下:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

其中没有设置ServerName,且提示这个站点将作为默认站点,即如果当请求域名不存在时,将显示该站点的内容。

2.现在在 /etc/apache2/sites-enabled 目录里,新创建一个虚拟站点 yun.anqun.org 的配置文件 111-yun_anqun_org.conf ,简化后的内容如下:

<VirtualHost *:80>
        ServerName yun.anqun.org
        DocumentRoot /var/www/html/yun.anqun.org
</VirtualHost>

3.保存后重启apache2服务,在浏览器里分别访问 http://yun.anqun.org/ , http://portal.anqun.org/, http://121.43.110.72/ ,结果显示,后两个网址访问到的都是默认站点的内容

bbs-aliyun-dongshan3-305413-1.png

bbs-aliyun-dongshan3-305413-2.png

bbs-aliyun-dongshan3-305413-3.png

所以,如果想不让他人的域名访问到自己的站点内容,可将默认站点设置为其它内容(或空白)即可。