Docker-alpine-nginx
alpine 安装nginx
1 | apk update |
问题1 nginx: [emerg] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)
解决:mkdir /var/run/nginx
问题2 nginx: [emerg] unknown directive "rtmp" in /etc/nginx/nginx.conf:16
解决:在/etc/nginx/nginx.conf
添加include /etc/nginx/modules/*.conf;
nginx常用调试
1 | #查看ngixn是否启动 |
nginx路径配置解释
1 | location /test { |
常用配置文件
1 | http { |
nginx 代理
正则匹配(
~
),URL包含weather
都会走代理1
2
3location ~ /weather/ {
proxy_pass http://apicloud.mob.com;
}前缀匹配(
^~
),前缀是/v1/weather/
开头的才走代理1
2
3location ^~ /v1/weather/ {
proxy_pass http://apicloud.mob.com;
}精确匹配(
=
),URL是/demo
多了少了都不行,才能进代理1
2
3location = /demo/ {
proxy_pass http://apicloud.mob.com;
}