-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpve-proxy.conf
More file actions
112 lines (95 loc) · 7.79 KB
/
pve-proxy.conf
File metadata and controls
112 lines (95 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# ───────────────────────────────────────────────────────────────────────────────
# 1) MAP BLOCK: translate incoming “Upgrade” header into a proper Connection header
# (necessary for WebSocket support)
# ───────────────────────────────────────────────────────────────────────────────
map $http_upgrade $connection_upgrade {
default upgrade; # if client asks to “Upgrade” (e.g. WebSocket), keep it open
'' close; # otherwise, Nginx will close the connection
}
# ───────────────────────────────────────────────────────────────────────────────
# 2) SERVER BLOCK: listen on port 8443 with SSL for Proxmox Proxy
# ───────────────────────────────────────────────────────────────────────────────
server {
listen 8443 ssl; # HTTPS port (you can change to 443 or another)
server_name 192.168.86.87; # your server’s hostname or IP address
# ───────────────────────────────────────────────────────────────────────────
# SSL SETTINGS: point to your certificate and private key
# ───────────────────────────────────────────────────────────────────────────
ssl_certificate /etc/ssl/nginx/pve-proxy.crt;
ssl_certificate_key /etc/ssl/nginx/pve-proxy.key;
# ───────────────────────────────────────────────────────────────────────────
# ALLOW LARGE UPLOADS: unlimited client body size for ISO uploads, etc.
# ───────────────────────────────────────────────────────────────────────────
client_max_body_size 0;
# ───────────────────────────────────────────────────────────────────────────
# SANITY CHECK: simple Lua that logs on every reload to confirm Lua’s working
# ───────────────────────────────────────────────────────────────────────────
access_by_lua_block {
ngx.log(ngx.ERR, "[GPU] nginx+lua is alive")
}
# ───────────────────────────────────────────────────────────────────────────
# LOCATION #1: catch Proxmox VM start/stop API calls (hook GPU script)
# ───────────────────────────────────────────────────────────────────────────
location ~ ^/api2/(?:json|extjs)/nodes/[^/]+/qemu/\d+/status/(?:start|stop|shutdown|reboot|reset)$ {
access_by_lua_block {
local uri = ngx.var.request_uri
local vmid = uri:match("/qemu/(%d+)/status")
local action = uri:match("/status/(%a+)$")
local mode = (action=="start") and "pre-start" or "post-stop"
ngx.log(ngx.ERR, "[GPU] vm", vmid, "→ hooking ", action, " as ", mode)
local cmd = "sudo /usr/local/share/pve-hook-scripts/gpu-autopick.sh "
.. vmid .. " " .. mode .. " 2>&1"
local h = io.popen(cmd)
local out = h:read("*a")
local ok, typ, st = h:close()
ngx.log(ngx.ERR,
"[GPU] cmd=", cmd,
" ok=", tostring(ok),
" type=", typ or "-",
" stat=", tostring(st),
" output=", out:gsub("\n","\\n"))
}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Authorization $http_authorization;
proxy_set_header Cookie $http_cookie;
proxy_set_header CSRFPreventionToken $http_csrfpreventiontoken;
proxy_ssl_verify off;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_pass https://127.0.0.1:8006;
}
# ───────────────────────────────────────────────────────────────────────────
# LOCATION #2 (DEFAULT): UI, API, WebSockets, file uploads, etc.
# ───────────────────────────────────────────────────────────────────────────
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Authorization $http_authorization;
proxy_set_header Cookie $http_cookie;
proxy_set_header CSRFPreventionToken $http_csrfpreventiontoken;
proxy_ssl_verify off;
# ───────────────────────────────────────────────────────────────────────
# STREAM UPLOADS: don’t buffer the request body (ISO uploads, backups)
# ───────────────────────────────────────────────────────────────────────
proxy_request_buffering off;
proxy_buffering off;
# long timeouts for slow uploads or web console
proxy_connect_timeout 60s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
proxy_pass https://127.0.0.1:8006;
}
# ───────────────────────────────────────────────────────────────────────────
# LOGGING
# ───────────────────────────────────────────────────────────────────────────
access_log /var/log/nginx/pve-proxy-access.log;
error_log /var/log/nginx/pve-proxy-error.log debug;
}