-
Notifications
You must be signed in to change notification settings - Fork 957
feat: nginx config for self hosting #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2dbec99
84bad0c
6b86d35
a67d93a
69aedcb
50ec361
235d731
e365104
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,45 +1,24 @@ | ||||||
server { | ||||||
listen 80; | ||||||
server_name _; | ||||||
|
||||||
root /var/www/maxun; | ||||||
index index.html; | ||||||
|
||||||
# Serve the frontend | ||||||
location / { | ||||||
root /usr/share/nginx/html; | ||||||
try_files $uri $uri/ /index.html; | ||||||
} | ||||||
|
||||||
location /api { | ||||||
proxy_pass http://localhost:8080; | ||||||
proxy_http_version 1.1; | ||||||
proxy_set_header Upgrade $http_upgrade; | ||||||
proxy_set_header Connection 'upgrade'; | ||||||
proxy_set_header Host $host; | ||||||
proxy_cache_bypass $http_upgrade; | ||||||
|
||||||
# Add timeout configurations | ||||||
proxy_connect_timeout 60s; | ||||||
proxy_send_timeout 60s; | ||||||
proxy_read_timeout 60s; | ||||||
|
||||||
# Add error handling | ||||||
proxy_intercept_errors on; | ||||||
error_page 502 503 504 /50x.html; | ||||||
} | ||||||
|
||||||
location ~ ^/(record|workflow|storage|auth|integration|proxy|api-docs) { | ||||||
proxy_pass http://localhost:8080; | ||||||
|
||||||
# Proxy for backend | ||||||
location ^/(auth|storage|record|workflow|robot|proxy|api-docs|api)(/|$) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify that the regex location pattern captures all required API endpoints. The regex pattern 🏁 Script executed: #!/bin/bash
# Verify if there might be other API endpoints in the codebase that should be included in the nginx regex
# Look for API route definitions in the codebase
echo "Searching for potential API routes defined in the codebase..."
rg -g "*.{js,ts,jsx,tsx}" "router\.(get|post|put|delete|patch)\s*\(\s*['\"]\/[^/]+" --json | jq -r ".data.lines.text" | sort | uniq Length of output: 434 🏁 Script executed: #!/bin/bash
# Corrected search for API route prefixes in JS/TS files using PCRE
echo "Searching for API route prefixes defined in the codebase..."
rg -P -g '*.{js,ts,jsx,tsx}' "router\.(?:get|post|put|delete|patch)\(\s*['\"]\/([^\/]+)" --only-matching --replace '$1' | sort -u Length of output: 1975 Update nginx location regex to include missing API prefixes The current pattern only matches • Suggested diff: - location ^/(auth|storage|record|workflow|robot|proxy|api-docs|api)(/|$) {
+ location ^/(auth|storage|record|workflow|robots|integration|proxy|api-docs|api)(/|$) { 📝 Committable suggestion
Suggested change
|
||||||
proxy_pass http://localhost:8080; # change as per your setup | ||||||
proxy_http_version 1.1; | ||||||
proxy_set_header Upgrade $http_upgrade; | ||||||
proxy_set_header Connection 'keep-alive'; # Ensure connections remain open | ||||||
proxy_set_header Connection 'upgrade'; | ||||||
proxy_set_header Host $host; | ||||||
Comment on lines
17
to
19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard-coding Sending # place this once in the http{} block
map $http_upgrade $connection_upgrade {
default close;
websocket upgrade;
}
# inside the location block
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade; |
||||||
proxy_cache_bypass $http_upgrade; | ||||||
|
||||||
# Timeout configurations | ||||||
proxy_connect_timeout 60s; | ||||||
proxy_send_timeout 60s; | ||||||
proxy_read_timeout 60s; | ||||||
|
||||||
# Error handling for these routes | ||||||
proxy_intercept_errors on; | ||||||
error_page 502 503 504 /50x.html; | ||||||
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 $scheme; | ||||||
} | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
default_server
or a concrete hostname to avoid name-based routing issuesWith
server_name _;
Nginx will only serve this block when no otherserver_name
matches.If another vhost is added later, requests may unexpectedly be routed elsewhere.
Safest options:
or replace
_
with your real hostname(s) so that routing is explicit.📝 Committable suggestion