
nginx配置文件nginx.conf详细讲解(1)
反正我看起来像个猪八戒的画像,好像是画的跑偏了,不管了,谁让鄙人的画画水准太次呢。。。
不过我到是认为这样看起来记忆会更加深刻些。好,今天就到这,下章我们来正经的讲下基于此图的各个模块的详细内容。
发布日期:2021-05-07 10:54:51
浏览次数:22
分类:精选文章
本文共 3112 字,大约阅读时间需要 10 分钟。
在实际工作中,我们很多的时候都会用到nginx做相应的代理服务,有的童鞋和我反馈,经理(laoshi),我总是记不住nginx配置文件中应该如何配置,nginx.conf中都有哪些模块配置内容,如何配置呢?
好,为了方便大家理解,我来为大家分四章节来讲解这个问题。
1.nginx安装完毕后自动生成的nginx.conf配置文件。

2.配置文件内容记录
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { 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 on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name skyfans; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #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; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}}
3.配置文件模块讲解
根据配置文件的内容,我们不难看出,conf配置文件中分类为如下几大模块:main、events、http、server 、location。
其实我们常用的要比目前体现出的模块更多,还多了stream、upstream模块。是不是听起来感觉还是有点多,记不住,好,我们来看一张图(鄙人亲自所画的图),本来是针对于技术的讲解的很正规的一个conf架构图的内容,结果画画就淘气的画成了这样。


发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年04月02日 02时07分13秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
上周热点回顾(9.28-10.4)
2021-05-09
上周热点回顾(5.2-5.8)
2021-05-09
上周热点回顾(5.9-5.15)
2021-05-09
.NET跨平台之旅:将示例站点升级至 .NET Core 1.1 Preview 1
2021-05-09
上周热点回顾(1.16-1.22)
2021-05-09
上周热点回顾(1.23-1.29)
2021-05-09
上周热点回顾(3.20-3.26)
2021-05-09
上周热点回顾(4.24-4.30)
2021-05-09
[故障公告]博客站点1台负载均衡遭遇流量攻击,造成联通与移动用户无法正常访问
2021-05-09
上周热点回顾(5.1-5.7)
2021-05-09
上周热点回顾(6.19-6.25)
2021-05-09
云计算之路-阿里云上:docker swarm 集群故障与异常
2021-05-09
上周热点回顾(2.19-2.25)
2021-05-09
云计算之路-阿里云上:博客web服务器轮番CPU 100%
2021-05-09
云计算之路-阿里云上:服务器CPU 100%问题是memcached连接数限制引起的
2021-05-09
上周热点回顾(3.26-4.1)
2021-05-09
上周热点回顾(6.25-7.1)
2021-05-09
【故障公告】10:30-10:45 左右 docker swarm 集群节点问题引发故障
2021-05-09
工作半年的思考
2021-05-09