37 lines
1.2 KiB
Nginx Configuration File
37 lines
1.2 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# Serve the React app (static files)
|
|
location / {
|
|
root /var/www/html; # React build output directory
|
|
try_files $uri $uri/ /index.html; # Ensure React routing works properly with single-page app
|
|
}
|
|
|
|
# Proxy API requests to Laravel (assuming Laravel is running on port 9000)
|
|
location /api/ {
|
|
proxy_pass http://laravel-app:9000; # Laravel service name from Docker Compose
|
|
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;
|
|
}
|
|
|
|
# Optionally, handle assets like images or other media files
|
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|txt|xml)$ {
|
|
expires 365d;
|
|
}
|
|
|
|
# Handle other static files
|
|
location /static/ {
|
|
root /var/www/html; # React static files
|
|
}
|
|
|
|
# Prevent caching for the Laravel dynamic content
|
|
location ~ \.php$ {
|
|
fastcgi_pass laravel-app:9000; # Forward PHP requests to the Laravel app
|
|
fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
|
|
include fastcgi_params;
|
|
}
|
|
}
|