centos7设置IP地址

centos7设置IP地址并启用网络的方法:

vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static    #static为设置固定IP,dhcp为启用自动获取IP
DEFROUTE=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=1.2.4.8
NAME=ens33
UUID=2f6b0f22-986b-4e52-b1fb-850f6ec927e4
DEVICE=ens33
ONBOOT=yes    #设置开机自动启动网络

wget raw.githubusercontent.com Unable to establish SSL connection 无法建立SSL连接 解决方法

用wget下载github上面文件的时候经常会发生Unable to establish SSL connection的情况,例如:

[root@localhost ~]# wget https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json 
--2020-12-17 09:44:41--  https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.228.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.228.133|:443... connected.
Unable to establish SSL connection.

一般情况下,在命令后面加上--no-check-certificate不验证ssl证书即可解决,但是有时候加了参数还是不行。

wget https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json --no-check-certificate

Unable to establish SSL connectionUnable to establish SSL connection

宝塔nginx禁止直接通过IP访问网站

在宝塔建站过程中如何禁止通过IP直接访问网站呢?方法如下:

如果listen没有设置default,那么可以这样

server {
listen 80;
server_name _;
return 404;
}

如果设置了default的话,上面那样做就不太好用了,可以在server{}里加入下面的判断,位置加在server_name下面location上面就行,对于开启https站定,同样有效。

if ( $host ~* "\d+\.\d+\.\d+\.\d+" ) {
return 404;
}