nginx.conf 基础配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
### 全局块开始###
 
#配置允许运行nginx服务器的用户和用户组
user  nobody;
 
#配置允许nginx进程生成的worker process 数
worker_processes  1;
 
#配置nginx服务器运行对错误日志的存放路径
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#配置nginx服务器运行时的pid文件存放路径和名称
pid        logs/nginx.pid;
 
### 全局块结束###
 
 
### events块开始###
 
events {
    #配置事件驱动模型
    use epoll;
    #配置最大连接数
    worker_connections  1024;
}
 
### events块结束###
 
 
 
### 全局块结束###
 
 
### HTTP块开始###
http {
    # 定义MIME-Type ,查看mime.types文件
    include       mime.types;
    default_type  application/octet-stream;
 
    #配置请求处理日志的格式
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
     
    # 配置允许使用sendfile方式传输
    sendfile        on;
     
    #tcp_nopush     on;
 
    #配置连接超时时间
    keepalive_timeout  65;
 
    #gzip  on;
 
    ### server块开始###
    ### 配置虚拟主机myServer1###
    server {
        # 配置监听端口和主机名称(基于名称)
        listen       80;
        server_name  myServer1;
 
        #charset koi8-r;
 
        #配置请求处理日志存放路径
        access_log  logs/host.access.log  main;
 
        # 配置处理/service1/location1 请求的location
        location /service1/location1 {
            root   /myweb;
            index  index1.html;
        }
         
        # 配置处理/service1/location2 请求的location
        location /service1/location2 {
            root   /myweb;
            index  index2.html;
        }
 
        # 配置错误页面
        error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    ### 配置虚拟主机myServer2###
       server {
        # 配置监听端口和主机名称(基于ip)
        listen       8082;
        server_name  192.168.1.3;
 
        #charset koi8-r;
 
        #配置请求处理日志存放路径
        access_log  logs/host.access.log;
 
        # 配置处理/service2/location1 请求的location
        location /service2/location1 {
            root   /myweb;
            index  index2.html;
        }
         
        # 对location的uri进行更改
        location /svr2/loc2 {
            alias /myweb/server2/location2;
            index  index.svr2-loc2.htm;
        }
 
        # 错误页面404.html 做了重定向
        error_page  404              /404.html;
 
        location = /404.html {
            root   /myweb;
            index  404.htm;
        }
    }
    ### server块结束###
 
}
### HTTP块结束###

  

posted @   zzhi.wang  阅读(265)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示