进入nginx目录 编辑配置文件
nano /usr/local/nginx/conf/nginx.conf
删除已经配置好的 sever块
配置虚拟主机 进入
cd /usr/local/nginx/conf/vhost
创建新的文件
touch XXXX.conf
编辑 XXXX.conf
大概思路是 通过80端口的访问全部转发到其他网页上
server
{
listen 80 default_server reuseport;
#listen [::]:80 default_server ipv6only=on;
server_name localhost;
rewrite ^(.*) https://diary.kaiyi.monster;
}
配置443端口的文件
server {
listen 443 ssl;
server_name localhost;
index index.html index.htm index.php;
root /home/wwwroot/default;
ssl_certificate /2b/3b.crt;
ssl_certificate_key /2b/4b.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/nmsl.log;
}
记得改配置文件 还有域名的证书
nginx -t (检查配置文件是否正确)
lnmp nginx restart (重启nginx)
即可看到效果