Nginx禁止从IP访问

Nginx禁止从IP访问

Administrator 510 2022-08-01

证书

防止从443访问及从证书中找出域名

  1. 创建私钥:
openssl genrsa -des3 -out server.key 1024
  1. 去除私钥中的密码:
openssl rsa -in server.key -out server.key
  1. 创建签名请求证书:
openssl req -new -key server.key -out server.csr
  1. 生成SSL证书:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

nginx配置

server {
   listen 80;
   listen 443 ssl;
   return 444;
ssl_certificate    /www/wwwroot/server.crt;
ssl_certificate_key    /www/wwwroot/server.key;
}