mirror of
https://github.com/adityachandelgit/BookLore.git
synced 2025-08-16 17:02:23 +00:00
55 lines
2.0 KiB
Nginx Configuration File
55 lines
2.0 KiB
Nginx Configuration File
# the events block is required
|
|
events {}
|
|
|
|
http {
|
|
# include the default mime.types to map file extensions to MIME types
|
|
include /etc/nginx/mime.types;
|
|
|
|
# Set max request body size to 100MB (adjust as needed)
|
|
client_max_body_size 1000M;
|
|
|
|
server {
|
|
listen 6060; # Listen on port 6060 for both API and UI
|
|
|
|
# Set the root directory for the server (Angular app)
|
|
root /usr/share/nginx/html;
|
|
|
|
# Set the default index file for the server
|
|
index index.html;
|
|
|
|
# Serve Angular UI
|
|
location / {
|
|
try_files $uri $uri/ /index.html; # Fallback to index.html for Angular routing
|
|
|
|
location ~* \.mjs$ {
|
|
# target only *.mjs files
|
|
# now we can safely override types since we are only
|
|
# targeting a single file extension.
|
|
types {
|
|
text/javascript mjs;
|
|
}
|
|
}
|
|
}
|
|
|
|
# Proxy API requests that start with /api/ to the backend
|
|
location /api/ {
|
|
proxy_pass http://localhost:8080; # Backend API running on port 8080
|
|
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_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
# Proxy WebSocket requests (ws://) to the backend
|
|
location /ws {
|
|
proxy_pass http://localhost:8080/ws; # Backend WebSocket endpoint
|
|
proxy_http_version 1.1; # Ensure HTTP 1.1 is used for WebSocket connection
|
|
proxy_set_header Upgrade $http_upgrade; # Pass the upgrade header
|
|
proxy_set_header Connection 'upgrade'; # Pass the connection header
|
|
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_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|
|
} |