美文网首页
nginx配置

nginx配置

作者: 点一下我的id | 来源:发表于2020-09-03 07:07 被阅读0次
 
#全局模块
events {
    #events模块
}

http 
{

   #http全局模块
 
    server 
    {
    
        #server全局模块
     
        location [PATTERN]{
           #location模块
        }
    }

}  
第一个原本的配置文件上是注释的,这里指的是nginx的用户权限,
user nobody;

设置最大的工作衍生进程数 这里默认是1
worker_processes 1

最大的连接数 设置最大的连接数默认为1024个连接数 
events {
    worker_connections  1024;
}

Http 的主要设置,这里可以添加多个server

http {
每一个Server都是一个服务
server{
    #这里是过滤请求,/是所有请求都可以
    location /{
        
    }
}

server下设置通过域名访问,禁止ip访问

  server {
        server_name  www.xxxx.com; #这里是你需要访问的域名地址
if ($host != 'www.xxxx.com'){
   return 403;
}
    }

参考

https://www.jianshu.com/p/734ef8e5a712
https://blog.csdn.net/qq_15724141/article/details/83346093
禁止ip访问,通过域名访问:https://www.cnblogs.com/weifeng1463/p/9197971.html

相关文章

网友评论

      本文标题:nginx配置

      本文链接:https://www.haomeiwen.com/subject/rdbesktx.html