38 lines
1.1 KiB
Nginx Configuration File
38 lines
1.1 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# Serve the React app (static files)
|
|
location / {
|
|
root /usr/share/nginx/html; # Point to React build output
|
|
try_files $uri $uri/ /index.html; # Ensure React routing works
|
|
index index.html;
|
|
}
|
|
|
|
# Proxy API requests to Laravel
|
|
location /api/ {
|
|
proxy_pass http://laravel-app:9000;
|
|
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;
|
|
}
|
|
|
|
# Handle PHP files for Laravel
|
|
location ~ ^/index.php(/|$) {
|
|
fastcgi_pass laravel-app:9000;
|
|
fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
|
|
include fastcgi_params;
|
|
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
|
}
|
|
|
|
# Serve static files (e.g., from Laravel public)
|
|
location /static/ {
|
|
root /var/www/html/public; # Laravel static files
|
|
}
|
|
|
|
# Cache static assets
|
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|txt|xml)$ {
|
|
expires 365d;
|
|
}
|
|
} |