obsidian-notes/工具/Nginx.md
CSSC-WORK\murmur 3e6078442b init version
2024-04-15 11:19:57 +08:00

107 lines
3.4 KiB
Markdown

反代可方便域名直接访问内部服务,避免输入端口号
# [Nginx Proxy Manager](https://nginxproxymanager.com/)
## 哪吒监控配置示例
```nginx
#PROXY-START/
location / {
proxy_pass http://172.17.0.1:8080;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
}
location ~ ^/(ws|terminal/.+)$ {
proxy_pass http://172.17.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
}
#PROXY-END/
```
以上配置转发外`域名:80`到`内部:8080`,其中`172.17.0.1`为docker地址
## gotify推送配置示例
参见[官方文档](https://gotify.net/docs/nginx)
```nginx
#PROXY-START/
location / {
proxy_pass http://172.17.0.1:8080;
proxy_http_version 1.1;
# Ensuring it can use websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_redirect http:// $scheme://;
# The proxy must preserve the host because gotify verifies the host with the origin
# for WebSocket connections
proxy_set_header Host $http_host;
# These sets the timeout so that the websocket can stay alive
proxy_connect_timeout 1m;
proxy_send_timeout 1m;
proxy_read_timeout 1m;
}
#PROXY-END/
```
反代到子目录时添加`rewrite ^/gotify(/.*) $1 break;`
## alist、gitea反代到子路径示例
```nginx
location /alist/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://172.17.0.1:8017/alist/;
# the max size of file to upload
client_max_body_size 20000m;
}
location /gitea/ {
client_max_body_size 512M;
# make nginx use unescaped URI, keep "%2F" as is
rewrite ^ $request_uri;
rewrite ^/gitea(/.*) $1 break;
proxy_pass http://172.17.0.1:8016$uri;
# other common HTTP headers, see the "Nginx" config section above
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
}
#PROXY-START/
location /notes/ {
proxy_pass http://172.17.0.1:8018;
proxy_http_version 1.1;
rewrite ^/notes(/.*) $1 break;
# Ensuring it can use websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_redirect http:// $scheme://;
# The proxy must preserve the host because gotify verifies the host with the origin
# for WebSocket connections
proxy_set_header Host $http_host;
# These sets the timeout so that the websocket can stay alive
proxy_connect_timeout 1m;
proxy_send_timeout 1m;
proxy_read_timeout 1m;
}
#PROXY-END/
```