Created
June 26, 2022 07:56
-
-
Save phxswjjj/19c72e1d5415912db89ab276fb595748 to your computer and use it in GitHub Desktop.
nginx config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# global 配置 | |
worker_processes auto; | |
# events | |
events { | |
worker_connections 1024; | |
} | |
# http | |
http { | |
upstream group1 { | |
server localhost:80 weight=1; | |
server localhost:81 weight=2; | |
} | |
proxy_next_upstream error timeout http_503; | |
server { | |
# 服務監聽 port | |
listen 80; | |
listen 443; | |
# 匹配的服務名稱 | |
# server_name localhost example.com; | |
# 匹配的路徑 | |
location / { | |
# 轉至指定 url | |
proxy_pass http://group1/; | |
} | |
# 使用「=」完全比對 | |
# 權重最高 | |
location = / { | |
return 200 'hello /'; | |
} | |
# 使用「^~」表示比對開頭字串 | |
# 權重第二 | |
location ^~ /a { | |
return 200 'hello /a'; | |
} | |
# 使用正規表達式比對 | |
# 權重第三 | |
# 權重一樣則以匹配字數較多的為主,再來是定義順序 | |
location ~ /\w { | |
return 200 'hello \w'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment