chore: switch to Dockerfile and Apache to resolve Nixpacks Nginx 502 Bad Gateway
This commit is contained in:
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM php:8.3-apache
|
||||
|
||||
# Copy the application files to the Apache web root
|
||||
COPY . /var/www/html/
|
||||
|
||||
# Ensure proper permissions
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
|
||||
# Replace the default Apache port (80) with the dynamic PORT environment variable provided by Railway, then start Apache
|
||||
CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && apache2-foreground
|
||||
@@ -1,77 +0,0 @@
|
||||
worker_processes 5;
|
||||
daemon off;
|
||||
|
||||
worker_rlimit_nofile 8192;
|
||||
|
||||
events {
|
||||
worker_connections 4096; # Default: 1024
|
||||
}
|
||||
|
||||
http {
|
||||
include $!{nginx}/conf/mime.types;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] $status '
|
||||
'"$request" $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stdout;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
|
||||
|
||||
server {
|
||||
listen 0.0.0.0:${PORT};
|
||||
server_name localhost;
|
||||
|
||||
$if(NIXPACKS_PHP_ROOT_DIR) (
|
||||
root ${NIXPACKS_PHP_ROOT_DIR};
|
||||
) else (
|
||||
root /app;
|
||||
)
|
||||
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
|
||||
index index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
$if(IS_LARAVEL) (
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
) else ()
|
||||
|
||||
$if(NIXPACKS_PHP_FALLBACK_PATH) (
|
||||
location / {
|
||||
try_files $uri $uri/ ${NIXPACKS_PHP_FALLBACK_PATH}?$query_string;
|
||||
}
|
||||
) else ()
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
$if(IS_LARAVEL) (
|
||||
error_page 404 /index.php;
|
||||
) else ()
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
include $!{nginx}/conf/fastcgi_params;
|
||||
include $!{nginx}/conf/fastcgi.conf;
|
||||
|
||||
# --- CUSTOM: INCREASE BUFFERS TO FIX 502 BAD GATEWAY ---
|
||||
fastcgi_buffers 64 32k;
|
||||
fastcgi_buffer_size 64k;
|
||||
fastcgi_busy_buffers_size 64k;
|
||||
fastcgi_max_temp_file_size 0;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user