NGINX学习笔记
1、简单配置
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
//配置转发的服务器映射
upstream serverWmx{
server 192.168.31.111:8890;
}
server {
listen 8077;//拦截端口
server_name localhost;//拦截域名
location /zuul/ {
proxy_pass http://serverWmx;//转发域名
root html;
index index.html index.htm;
}
#处理静态文件请求
#若传入url 为 localhost:8077/test/a.jpg 转发路径则为 C:/Users/Administrator/Desktop/test/a.jpg
location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
root "C:/Users/Administrator/Desktop/";
index index.html index.htm;
}
#若传入url 为 localhost:8077/kkkk/a.jpg 转发路径则为 C:/Users/Administrator/Desktop/a.jpg
location ^~ /KKKK/ {
root "C:/Users/Administrator/Desktop/";
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
2、include用法
在conf目录下建立一个extra(命名自定义)文件夹,nginx的主配置文件为nginx.conf,主配置文件所包含的所有虚拟主机的子配置文件会统一放入extra目录中,虚拟主机的配置文件会按照网站的域名或者功能取名,例如www.conf bbs.conf blog.conf 等
参考文章
3、nginx相关指令
https://www.runoob.com/w3cnote/nginx-setup-intro.html
https://blog.csdn.net/weixin_30363817/article/details/99263226