-
Notifications
You must be signed in to change notification settings - Fork 21
use nginx for handling and proxy request to API and Web UI #15
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f9af660
use nginx for handling request
elavol 022bef2
Use /backend, not /api (/api is already used)
Blaumaus f2d0f4f
BASE_URL; add conditions for nginx start
Blaumaus c2d9f47
api -> backend
Blaumaus bb71ca7
Use descriptive language
Blaumaus aefbba5
Config hardening
Blaumaus 98c6807
Fix config for websocket support
Blaumaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,68 @@ | ||
| map $http_upgrade $connection_upgrade { | ||
| default upgrade; | ||
| "" close; | ||
| } | ||
|
|
||
| server { | ||
| listen 81; | ||
| listen [::]:81; | ||
| # server_name swetrix.yourdomain.com; | ||
| listen 80; | ||
| listen [::]:80; | ||
| server_name _; | ||
|
|
||
| location / { | ||
| proxy_pass http://localhost:80; | ||
| # security headers | ||
| add_header X-XSS-Protection "1; mode=block" always; | ||
| add_header X-Content-Type-Options "nosniff" always; | ||
| add_header Referrer-Policy "strict-origin-when-cross-origin" always; | ||
| add_header Permissions-Policy "interest-cohort=()" always; | ||
| add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; | ||
|
|
||
| # Keep /backend/ prefix; this is used to route requests to the Swetrix API. | ||
| location /backend/ { | ||
| proxy_pass http://swetrix-api:5005/; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| } | ||
| } | ||
|
|
||
| server { | ||
| listen 8081; | ||
| listen [::]:8081; | ||
| # server_name api.swetrix.yourdomain.com; | ||
| server_name _; | ||
| # Proxy headers | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection $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 $scheme; | ||
| proxy_set_header X-Forwarded-Host $host; | ||
| proxy_set_header X-Forwarded-Port $server_port; | ||
|
|
||
| # Proxy buffering (prevents truncated responses for large files) | ||
| proxy_buffering on; | ||
| proxy_buffer_size 256k; | ||
| proxy_buffers 32 512k; | ||
| proxy_busy_buffers_size 4m; | ||
| proxy_max_temp_file_size 1024m; | ||
| } | ||
|
|
||
| location / { | ||
| proxy_pass http://localhost:8080; | ||
| proxy_pass http://swetrix:3000; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
|
||
| # Proxy headers | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection $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 $scheme; | ||
| proxy_set_header X-Forwarded-Host $host; | ||
| proxy_set_header X-Forwarded-Port $server_port; | ||
|
|
||
| # Proxy buffering (prevents truncated responses for large files) | ||
| proxy_buffering on; | ||
| proxy_buffer_size 256k; | ||
| proxy_buffers 32 512k; | ||
| proxy_busy_buffers_size 4m; | ||
| proxy_max_temp_file_size 1024m; | ||
| } | ||
|
|
||
| gzip on; | ||
| gzip_vary on; | ||
| gzip_proxied any; | ||
| gzip_comp_level 6; | ||
| gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.