config: set up nginx and static output for production deployment
This commit is contained in:
parent
3bb52d0927
commit
154b47935b
@ -4,5 +4,6 @@ import { defineConfig } from 'astro/config';
|
||||
import tailwind from '@astrojs/tailwind';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'static',
|
||||
integrations: [tailwind()]
|
||||
});
|
||||
37
nginx.conf
Normal file
37
nginx.conf
Normal file
@ -0,0 +1,37 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
# Root directory for static files.
|
||||
# This should match the directory where Astro's build output (e.g., from 'dist')
|
||||
# is copied in your Dockerfile (e.g., COPY --from=builder /app/dist /usr/share/nginx/html).
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
|
||||
# Serve Astro static site
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html =404;
|
||||
}
|
||||
|
||||
# Proxy API requests to the Node.js backend server.
|
||||
# The Node.js server is expected to be running on localhost:3000 inside the container.
|
||||
location /api/ { # Note the trailing slash here
|
||||
proxy_pass http://localhost:3000/api/; # And here. This ensures /api/foo becomes http://localhost:3000/api/foo
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade'; # Important for WebSocket, etc.
|
||||
proxy_set_header Host $host; # Preserves the original host header
|
||||
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_cache_bypass $http_upgrade; # Useful for avoiding caching issues during development or for dynamic content
|
||||
}
|
||||
|
||||
# Optional: Custom error pages
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
# Ensure you have a 50x.html file in your static assets root
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user