分类 云计算 下的文章

为阿里云ECS(CentOS 5)配置IPv6隧道地址

云友“ap6554s5w”希望 能在CentOS 5系统里配置IPv6地址,所以写此帖。

环境:ECS“经典网络”类型(网友“ifaceparty”提醒:如果是“专有网络”,需要将HE配置隧道地址命令中的IPv4地址修改为ECS实例的内网地址),CentOS 5.11 64位系统。

注意:如是苹果APP上架申请因无法IPv6-only访问被拒,请重点检查APP代码,苹果公司的参考文档并没有要求APP服务需要有IPv6地址:https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html

1.CentOS 5.11 64位系统,默认没有启用IPv6地址

2.编辑 /etc/sysctl.conf 文件,将其中三条禁用IPv6的设置更改为:

net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
````
 
3.编辑文件,/etc/modprobe.d/disable_ipv6.conf,将其中的两行都注释掉:[/code] 

alias net-pf-10 off

options ipv6 disable=1

![bbs-aliyun-dongshan3-304532-1.png][1]
 
4.编辑文件,/etc/sysconfig/network,将其中的 NETWORKING_IPV6=no 改为 NETWORKING_IPV6=yes 
NETWORKING_IPV6=yes
![bbs-aliyun-dongshan3-304532-2.png][2] 
 
5.重启系统,以让更改生效。系统重启后,运行 ifconfig 命令,可以看到IPv6的地址  
 
7.执行 HE 隧道地址配置例子中的 Linux-net-tools 命令,如本例是: 

ifconfig sit0 up
ifconfig sit0 inet6 tunnel ::216.218.221.6
ifconfig sit1 up
ifconfig sit1 inet6 add 2001:470:18:401::2/64
route -A inet6 add ::/0 dev sit1

![bbs-aliyun-dongshan3-304532-3.png][3] 
 
8.安装 nginx 后,启动 nginx ,可以看到在IPv6(:::80)里监听使用了  
![bbs-aliyun-dongshan3-304532-4.png][4] 
 
9.在其它IPv6的系统上,用 curl 测试 IPv6 域名和IP地址站点内容,正常。实践中,访问IPv6的网站内容可能较慢,这可能是因为提供隧道地址的网络与国内连接较慢 

curl 'http://yun.anqun.org' -so - | grep -iPo '(?<=)(.*)(?=)'
curl [2001:470:18:401::2] -so - | grep -iPo '(?<=)(.*)(?=)'
curl -6 'http://ipv6.anqun.org' -so - | grep -iPo '(?<=)(.*)(?=)'

![bbs-aliyun-dongshan3-304532-5.png][5] 
 
参考:https://tunnelbroker.net/ 


  [1]: https://liujia.anqun.org/usr/uploads/2019/06/09/802672251359026.png
  [2]: https://liujia.anqun.org/usr/uploads/2019/06/09/80268753090719.png
  [3]: https://liujia.anqun.org/usr/uploads/2019/06/09/80268887271176.png
  [4]: https://liujia.anqun.org/usr/uploads/2019/06/09/802682848492264.png

在 Windows 2008 系统为 phpstudy apache 不同网站配置不同SSL证书(SNI)

有云友提问,想为 phpstudy 套件里的 apache 配置SSL证书安全访问。

环境:Windows 2008 32位系统 , phpstudy 2016(apache 2.4)

过程:

1.下载,解压,初始化好 phpstudy
bbs-aliyun-dongshan3-304092-1.png

2.将下载好的证书放到apache目录下,如我将yun.anqun.org的SSL证书保存在apache/conf/ssl/yun里
bbs-aliyun-dongshan3-304092-2.png

3.通过phpstudy的管理菜单,编辑 httpd.conf 配置文件,将约在489行的,关于ssl配置的文件启用;
Include conf/extra/httpd-ssl.conf
bbs-aliyun-dongshan3-304092-3.png

4.编辑 httpd-ssl.conf 文件,按实际情况配置虚拟主机的ssl内容,如本例里的 yun.anqun.org 及 portal.anqun.org 的简要配置内容如下:

##
## SSL Virtual Host Context
##
<VirtualHost *:443>
        SSLEngine on
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
        SSLCertificateFile      "D:\phpStudy\Apache\conf\ssl\yun\213949634960268.pem"
        SSLCertificateKeyFile   "D:\phpStudy\Apache\conf\ssl\yun\213949634960268.key"
        ServerName      "yun.anqun.org"
        DocumentRoot    "C:\www\yun.anqun.org"
</VirtualHost>
<VirtualHost *:443>
        SSLEngine on
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
        SSLCertificateFile      "D:\phpStudy\Apache\conf\ssl\portal\213466734260268.pem"
        SSLCertificateKeyFile   "D:\phpStudy\Apache\conf\ssl\portal\213466734260268.key"
        ServerName      "portal.anqun.org"
        DocumentRoot    "C:\www\portal.anqun.org"
</VirtualHost>

bbs-aliyun-dongshan3-304092-4.png

5.保存配置文件后,重启apache,在火狐浏览器里测试访问,显示结果正常
bbs-aliyun-dongshan3-304092-5.png

bbs-aliyun-dongshan3-304092-6.png

参考:https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html

在 Debian 8系统 为 nginx 不同网站配置不同SSL证书(SNI)

看到有云友想为站点配置https访问,本例实践一下:

环境:Debian 8 64位,nginx

目的:为两个站点(yun.anqun.org, portal.anqun.org)配置https访问。

前提:已经安装好了Web(nginx)和在阿里云申请下载了相应的SSL证书。

过程:

1.Debian 8 系统软件库中的nginx支持SNI功能
bbs-aliyun-dongshan3-303963-1.png

2.将站点SSL证书上传到合适的目录,如将.pem文件上传到 /etc/ssl/certs , 将.key文件上传到 /etc/ssl/private 目录。一般需将key文件设置为仅root可读写。
bbs-aliyun-dongshan3-303963-2.png

3.编辑站点yun.anqun.org的配置文件,增加SSL监听端口及证书路径,如本例站点yun.anqun.org的配置文件内容如下:

server {
       listen 80;
       listen 443 ssl;
      ssl_certificate   /etc/ssl/certs/yun_anqun_org.pem;
      ssl_certificate_key /etc/ssl/private/yun_anqun_org.key;
      ssl_session_timeout 5m;
      ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_prefer_server_ciphers on;
          
       server_name yun.anqun.org;
       root /var/www/yun.anqun.org;
       index index.html;
}

bbs-aliyun-dongshan3-303963-3.png

4.重新加载 nginx 服务,在Chrome浏览器里测试,正常显示https站点内容
bbs-aliyun-dongshan3-303963-4.png

bbs-aliyun-dongshan3-303963-5.png

参考:http://nginx.org/en/docs/http/configuring_https_servers.html

在Windows 2012 web服务器IIS 为不同网站配置不同SSL证书(SNI)

现在阿里云可以免费提供可用于设置https站点的SSL证书,且新版本的Web服务端通过SNI功能支持在同一个IP里设置多个https站点。

本例以Windows 2012 Web服务器IIS,为两个站点 portal.anqun.org 和 yun.anqun.org 配置(绑定)https。

前提条件:假设服务器已经安装好了Web服务角色,且新建好了站点; 已经从阿里云证书服务中下载到了相应的适合“IE8”的SSL证书。

步骤:

1.在IIS主页,点击“服务器证书”图标
bbs-aliyun-dongshan3-303904-1.png

2.在“服务器证书”页中,鼠标右击,选择“导入”,弹出“导入证书”对话框
bbs-aliyun-dongshan3-303904-2.png

bbs-aliyun-dongshan3-303904-3.png

3.在“导入证书”对话框里选择准备好的.pfx文件
bbs-aliyun-dongshan3-303904-4.png

4.完成导入后,会显示成功导入的证书信息
bbs-aliyun-dongshan3-303904-5.png

5.转到相应的站点,如鼠标右击 portal.anqun.org ,选择“编辑绑定”
bbs-aliyun-dongshan3-303904-6.png

6.在“网站绑定”对话框里,点击“添加”按钮
bbs-aliyun-dongshan3-303904-6.png

7.在“编辑网站绑定”对话框里,选择“https”的类型,勾选“需要服务器名称指示”,在“SSL证书”里选择相应的证书
bbs-aliyun-dongshan3-303904-8.png

bbs-aliyun-dongshan3-303904-9.png

8.在火狐浏览器里分别浏览https站点,显示正常
bbs-aliyun-dongshan3-303904-10.png

参考:https://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-server-name-indication-sni-ssl-scalability

在Debian 7系统里测试安装Ambra

感谢 tctia* 的支持。

有用户要求测试安装Ambra,现将过程记录,虽然未成功,但希望给其他人带来帮助。

环境:
软件:Debian 7.10 64位,JDK 7,tomcat 6,mysql server 5.5。
ECS配置:1核心,2GB内存。

个人总结:

  • Ambra官方网站里的文档相对较旧,很久没更新了
  • Ambra官方网站里提供的联系方法(邮件列表)无人审核,无法发邮件提问,获取帮助
  • Java生手(如我),不建议尝试,在前面两个原因前提下,完成测试有难度

过程:

1.更新软件源:
apt-get update

2.安装默认JDK版本(1.7.0_111)
apt-get install default-jdk

3.安装tomcat6
apt-get install tomcat6

4.安装mysql,假设设置mysql的密码为root
apt-get instal mysql-server

5.停止 tomcat6 服务,移走原有/var/lib/tomcat/webapps目录内容
service tomcat6 stop

6.用官方上手教程里方法,编译的webapp版本是2.9.5,官方PLOS支是2.11,这里下载官方编译好的2.11.war来测试,放到 /var/lib/tomcat/webapps/ROOT.war

wget http://ambraproject.org/maven2/release/org/ambraproject/ambra-webapp/2.11.0/ambra-webapp-2.11.0.war

7.从官方上手教程里下载相应的组件,如 tomcat-jdbc.jar, tomcat-juli.jar, log4j-1.2.14.jar 到 /usr/share/tomcat6/lib 目录(前两者是mysql连接要用到的,后边的是用于记录日志的),同时在该目录里创建log4j.properties的配置文件,让tomcat记录详细的输出信息

log4j.rootLogger=ERROR,consoleAppender
log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.consoleAppender.Target=System.out
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %c{1} - %m%n
log4j.logger.org.ambraproject=DEBUG
log4j.logger.org.ambraproject.ambra.configuration=FATAL

8.编辑tomcat配置文件,/etc/tomcat6/context.xml ,在标签间加入以下内容,其中 jdbc:mysql://localhost/ambra 中的 ambra 是程序要用到的数据库名称,上一行的password是数据库用户的密码,路径 /mytest/dongshan/ambra 是程序要用到的文件路径,这里随意创建了 /mytest/dongshan 的路径,请作相应的更改

<WatchedResource>WEB-INF/web.xml</WatchedResource>
  <Resource name="jdbc/AmbraDS"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    validationQuery="SELECT 1"
    testOnBorrow="true"
    driverClassName="com.mysql.jdbc.Driver"
    username="root"
    password="aqtest38"
    url="jdbc:mysql://localhost/ambra" />
<Resource name="ambra/FileStore"
    type="org.ambraproject.filestore.FileStoreService"
    factory="org.ambraproject.filestore.impl.LocalFileStoreFactory"
    baseDir="/mytest/dongshan"
    domain="ambra" />

bbs-aliyun-dongshan3-303673-1.png

9.创建好空数据库 ambra,导入从官方“上手教程”里的 ambra_schema.sql 数据库文件

10.创建ambra的配置文件,/etc/ambra/ambra.xml ,内容如下。这里主要是设置文件(ehcache.xml)和目录(ingest、ingestdestination、AmbraJournal和templates)的路径, 还有默认杂志名称(AmbraJournal),请根据实际情况修改:

<config>
  <ambra>
    <network>
      <hosts>
        <default>localhost</default>
        <ambra>${ambra.network.hosts.default}</ambra>
      </hosts>
    </network>
    <services>
      <ehcache>
        <configFileLocation>/mytest/dongshan/ehcache.xml</configFileLocation>
      </ehcache>
      <search>
        <server>
          <url>http://localhost:8080/solr</url>
        </server>
      </search>
      <documentManagement>
        <ingestSourceDir>/mytest/dongshan/ingest</ingestSourceDir>
        <ingestDestinationDir>/mytest/dongshan/ingestdestination</ingestDestinationDir>
      </documentManagement>
    </services>
    <virtualJournals>
      <templateDir>/mytest/dongshan/templates</templateDir>
      <default>AmbraJournal</default>
      <journals>AmbraJournal</journals>
    </virtualJournals>
  </ambra>
</config>

11.创建杂志目录(/mytest/dongshan/templates/journals/AmbraJournal/webapp)及配置文件,如 /mytest/dongshan/templates/journals/AmbraJournal/configuration/journal.xml,内容如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!--
  This file is the Ambra template for the Default AmbraJournal journal
-->
<config>
  <ambra>
    <!-- virtual journal config -->
    <virtualJournals>
      <AmbraJournal>
        <journal>AmbraJournal</journal>
        <eIssn>1111-2222</eIssn>
        <description>Ambra</description>
        <rules>
          <host>.*ambra.*</host>
        </rules>
        <url>http://ambrajournal.example.org</url>
        <!-- Does the journal have a taxonomy browser? -->
        <taxonomyBrowser>false</taxonomyBrowser>
        <ambra>
          <services>
            <feed>
              <title>Ambra Journal</title>
              <id>info:doi/10.1371/feed.ambr</id>
            </feed>
          </services>
        </ambra>
        <!-- Configuration keys for displaying recent articles tab widget on home page -->
        <recentArticles>
          <numDaysInPast>14</numDaysInPast>
          <numArticlesToShow>5</numArticlesToShow>
          <typeUriArticlesToShow>
            <articleTypeUri>http://rdf.plos.org/RDF/articleType/Research%20Article</articleTypeUri>
          </typeUriArticlesToShow>
        </recentArticles>
        <isIncludeInCrossJournalSearch>false</isIncludeInCrossJournalSearch>
      </AmbraJournal>
    </virtualJournals>
    <freemarker>
      <!--
        # This section defines the various journals and the css and javascript files which should be
        # included on each page as well as the page title.  The values within the <default> tag are used
        # if any of the values are missing in the <page> definitions.  Note, that the title, css, and
        # javascript level values are entirely replaced, they are not additive.  Override config files
        # may define values for each of those three variables and they will supsercede values present
        # in subsequent config values.  The lookup for values is as follows:
        # 1. Page defined in journal
        # 2. Default value defined in journal
        # 3. Page defined in default journal
        # 4. Default value in default journal
        # To define an empty value for a certain page so that it doesn't use defaults, just put the
        # element tag with no value, e.g. <javascript></javascript>
      -->
      <!--AmbraJournal-->
      <journal>
        <name>AmbraJournal</name>
        <metaKeywords>Ambra\, Default\, Journal</metaKeywords>
        <metaDescription>Ambra Journal: Defaults</metaDescription>
        <articleTitlePrefix>Ambra Journal :</articleTitlePrefix>
        <displayName>Ambra Journal</displayName>
        <default>
          <title>Ambra Journal : An Open-Access, Semantic, Journal Publishing System</title>
          <css>
            <file>/css/global.css</file>
            <file>/css/lte_ie7.css</file>
          </css>
          <javascript>
            <file>/javascript/js.js</file>
          </javascript>
        </default>
        <page>
          <name>/index.ftl</name>
          <css>
            <file>/css/global.css</file>
            <file>/css/lte_ie7.css</file>
          </css>
          <javascript>
            <file>/javascript/jquery-1.8.1.js</file>
            <file>/javascript/global.js</file>
          </javascript>
        </page>
      </journal>
    </freemarker>
  </ambra>
</config>

12.如果tomcat6提示缺少co请在相应的镜像站点下载 commons-logging-1.2-bin.tar.gz,将解压出来commons-logging-1.2.jar的文件,放到tomcat的lib目录/usr/share/tomcat6/lib
wget http://apache.mirror.iweb.ca//commons/logging/binaries/commons-logging-1.2-bin.tar.gz

13.启动tomcat6,在浏览器访问,看测试结果:
service tomcat6 start
bbs-aliyun-dongshan3-303673-2.png

bbs-aliyun-dongshan3-303673-4.png

14.如浏览器显示404页面找不到,请查看tomcat日志:
tail -300 /var/log/tomcat6/catalina.out
bbs-aliyun-dongshan3-303673-5.png

15.测试中,如果用官方PLOS树中的ambra-webapp-2.11.0.war,很可能会出现500错误,提示找不到 includes/article_variables.ftl 文件,我是直接将 /var/lib/tomcat6/webapps/ROOT/includes/global_variables.ftl 复制为 /var/lib/tomcat6/webapps/ROOT/includes/article_variables.ftl

freemarker.template.TemplateException: Error reading included file includes/article_variables.ftl

bbs-aliyun-dongshan3-303673-6.png

16.测试中,如果用自己编译的ambra-webapp-2.9.5.war,会出现缺少排版的内容页面
bbs-aliyun-dongshan3-303673-7.png

bbs-aliyun-dongshan3-303673-8.png

bbs-aliyun-dongshan3-303673-9.png

17.虽然官方文档里提到可以直接使用官方编译好ambra-admin.war,但放到webapps后,出现404出错,试用几个不同版本的ambra-amdin.ware,结果一样。
bbs-aliyun-dongshan3-303673-10.png

参考:http://ambraproject.org/trac/wiki/QuickStart