Nginx 安装SSL 以及其中的一些安全问题

以前都是图省事,直接使用cpanel 安装SSL,确实简单方便。现在除了两个server还在使用WHM 以外,其余的已经全部使用LNMP 架构了。

今天下午直接在nginx安装SSL,安装倒不麻烦,麻烦的是安装完成以后的安全隐患。

Nginx 在配置中就需要两个文件,一个是private key,这个是在生成CSR的时候一起生成的;另外一个是certification,这个就需要用生成的CSR 去一些SSL 服务商请求certificate

大概流程:

  1. 在服务器上使用Openssl 或者网上的一些工具,生成CSR 以及private Key. 建议使用在线工具直接生成2048 bits 的CSR 和 Private key,可以使用如下两个网站.

 

https://www.digicert.com/easy-csr/openssl.htm

https://www.thesslstore.com/ssltools/csr-generator.php

 

    2. 找一个txt 文档保存好CSR 以及private key

    3. 用生成的CSR 去SSL 服务商那里请求证书,这里建议使用rapidssl,来自于geotrust,便宜快速高效

    4. 等到rapidssl 把证书通过email 的形式发给你的时候,你就可以开始在nginx上安装SSL了

    5. 在nginx 的安装目录下,如果你是通过源代码编译的话,一般就是/usr/local/nginx, 建立一个SSL 文件,把通过email 得到的证书保存为ssl.crt, 把private key 保存为ssl.key

    6. 如果你使用rapidssl 的话,你还得把下载rapidssl intermediaCA certificate, 可以点击这里下载:https://knowledge.rapidssl.com/support/ssl-certificate-support/index?page=content&actp=CROSSLINK&id=INFO1548

使用SO28616

   7 在同一个目录下,把Intermediate CA certificate 保存为intermediate.crt, 然后把这个intermediate.crt 加在ssl.crt 后面才算完成整个证书

   cat intermediate.crt >> ssl.crt

   8 到目前为止,所有的准备工作都算完成,下一步就是配置nginx了,这个很简单,按照nginx 的官方文档

 

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

 

   主要是添加一下三个参数:

   listen XX.XX.XXX.XX:443 ssl;

   ssl_certificate /usr/local/nginx/ssl/ssl.crt;
   ssl_certificate_key /usr/local/nginx/ssl/ssl.key;

 

然后重新启动nginx 即可

一定不要忘记检查一下你的ssl 的安装是否正确: 

https://cryptoreport.rapidssl.com/checker/views/certCheck.jsp

这个网址会清楚的告诉你你安装的SSL 的安全隐患,其中比较著名的就是需要关闭SSLv3,也很简单, 在你的server 或者http block 里面加入如下命令即可:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # omit SSLv3 because of POODLE (CVE-2014-3566)

ls 命令参数大全

1. List Files using ls with no option

ls with no option list files and directories in bare format where we won’t be able to view details like file types, size, modified date and time, permission and links etc.

2 List Files With option –l

Here, ls -l (-l is character not one) shows file or directory, size, modified date and time, file or folder name and owner of file and it’s permission.

3. View Hidden Files with option -a

List all files including hidden file starting with ‘.‘.

4. List Files with Human Readable Format with option -lh

With combination of -lh option, shows sizes in human readable format.

5. List Files and Directories with ‘/’ Character at the end

Using -F option with ls command, will add the ‘/’ Character at the end each directory.

6. List Files in Reverse Order

The following command with ls -r option display files and directories in reverse order.

7. Recursively list Sub-Directories

ls -R option will list very long listing directory trees. See an example of output of the command.

8. Reverse Output Order

With combination of -ltr will shows latest modification file or directory date as last.

9. Sort Files by File Size

With combination of -lS displays file size in order, will display big in size first.

10. Display Inode number of File or Directory

We can see some number printed before file / directory name. With -i options list file / directory with inode number.

11. Shows version of ls command

Check version of ls command.

在数据备份和恢复中常用的工具rsync

rsync 在数据备份和恢复中非常的重要,比你直接用wget 来下载要方便的多,因为可以保持各种权限。

如果你的机器的ssh 的默认端口是22的话,可以直接使用下面的模板:

rsync -av /SRC/ -e ssh [email protected]:/DEST

这样就把src机器下的src 目录同步到了dest 机器侠的dest文件夹下

但是如果你的ssh 的默认端口不是22的话,就需要加一个parameter “-p”,但是这个这个参数和后面的value 是不能加空格分开的,我就因为这个小问题搜索了将近一个小时.

加入说你的ssh端口为8808,则需要使用如下的命令:

rsync -av /SRC/ -e ‘ssh -p8808’  [email protected]:/DEST

另外如果你想监控同步的progress的话,就需要加上一个–progress 的参数:

rsync -av –progress /SRC/ -e ‘ssh -p8808’ [email protected]:/DEST

或者

rsync -av -P /SRC/ -e ‘ssh -p8808’ [email protected]:/DEST

 

Also add -h to show human readable sizes (350M instead of 367071842)

 

mysql大数据库备份问题

这个问题经常遇到,自己研究了半天,对于大型的数据库,除了用专业的免费的开源的percona 的工具以外,就只有使用mysqldump 来导出,用mysql 来导入了。。

 

mysqldump 导出格式:

mysqldump -u root -p datbase_name > backup_output.sql

mysql 导入:

mysqldump -u root -p database_name < backup_output.sql

注意,在导入和导出的时候均需要在ssh console里面操作,鉴于国内的网络异常的不稳定,一旦ssh断掉,导入和导出就会断掉,所以建议使用国外的vps 来进行操作

 

CSF SSL问题

今天下午在服务器上新切了一个小鸡,装了一个CSF,结果过了一会CSF 发来error email alert:

 

Oops: Unable to download: Protocol scheme ‘https’ is not supported (Crypt::SSLeay or IO::Socket::SSL not installed)

 

说实话,以前真的没有见过这个error,google 了一下才发现原来是PERL 的module 被卸载了。。(估计是装LNMP卸载的。。LNMP 会卸载掉好多的module)

 

知道了原因,解决办法就很简单啦

yum install perl-Crypt-SSLeay perl-Net-SSLeay -y

然后重启CSF即可

关于VP*N routing 的理解

昨天有一台小VPS的梯子怎么也上不去了,debug了一天才发现原来是routing 的问题。平时一直没有时间仔细看一下梯子的routing,今天仔细解析一下:

在pptpd.conf上,我们通常会加入如下两句命令:

localip 192.168.9.1
remoteip 192.168.9.11-30 //表示vp000n客户端获得ip的范围

如此可见,pptp是将远程服务器和pptp客户端建立一个内网,用类似于192.168.9.0/24的网段,再将远程服务器的IP和localip进行动态NAT,用远程的服务器的IP做为gateway来访问外网

假如说远程服务器的IP是207.210.83.140,我们就需要在IPtable上添加一个NAT的命令:

iptables -t nat -A POSTROUTING -o eth0 -s 192.168.9.0/24 -j SNAT –to-source 207.210.83.140

表示所有用eth0网卡的source ip位192.168.9.0/24的数据包,他的source IP将会被改为207.210.83.140

或者如果这台服务器专门用来扶墙,就可以简单一点,更省事一点

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

MASQUERADE 表示自动获取服务器的默认地址,就不需要–to-source命令了。

在服务器只有一个IP的情况下是可以的,但是如果你有多个IP,最好使用–to-source来区分不同的出口IP

 

 

从一无所有到公司被收购,在哪个阶段加入创业公司最合适?

这是从36kr 看到的,感觉确实很有意义

编者按:本文作者 Tom Blomfield 是 Mondo 公司的联合创始人。在文中解读创业公司在各个阶段(没有融资、天使轮、A 轮、B 轮、C 轮、被收购)的工作状态,并分析了在每个不同阶段加入公司的的福利。

近几年,人们的想法发生了变化,越来越多的人想加入创业公司。这种现象大概是从社交媒体电影开始,这也可能只是一种巧合,但是我脑中浮现的画面是:一帮 MBA 的学生们坐在一起观看 Justin Timberlake 扮演社交媒体大亨 Sean Parker 的电影,想着真有 10 亿美元是一件多么酷的事情。

人们选择去创业公司上班时,常常会忽略一个最重要的因素:公司的规模和阶段。我认为这比行业或者公司的想法更重要。更多