internal communication in railway not working.

I am trying to deploy a laravel application in docker. Due to certain requirements I need to deploy it in two containers. one laravel container which runs php-fpm and another one is nginx server. I have enable private network for both the containers and I named the fpm contanier private domain app. Now if I use app:9000 in the proxy pass it is not working getting host not found in upstream "app" in /etc/nginx/conf.d/default.conf:30 error. everthing works for me in local. can someone help on this ?
11 Replies
Percy
Percy5mo ago
Project ID: ba101f40-f9ad-4be5-a531-ccc43a641df6
Karthick K
Karthick K5mo ago
project id : ba101f40-f9ad-4be5-a531-ccc43a641df6
Brody
Brody5mo ago
is nginx just a proxy? what else is it doing?
Karthick K
Karthick K5mo ago
this is nginx config added
server {
gzip on;
gzip_proxied any;
gzip_types text/plain application/json;
gzip_min_length 1000;

listen 80;
listen [::]:80;
server_name localhost;

root /var/www/public;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 150;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /.ht {
deny all;
}

# Healthcheck
location = /health_check {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"UP"}';
}

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;

add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header Referrer-Policy 'same-origin';
}
server {
gzip on;
gzip_proxied any;
gzip_types text/plain application/json;
gzip_min_length 1000;

listen 80;
listen [::]:80;
server_name localhost;

root /var/www/public;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 150;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /.ht {
deny all;
}

# Healthcheck
location = /health_check {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"UP"}';
}

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;

add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header Referrer-Policy 'same-origin';
}
docker config
FROM nginx:stable-alpine

# Copy custom configuration file
COPY infra/nginx/default.conf /etc/nginx/conf.d/default.conf
ADD public /var/www/public
FROM nginx:stable-alpine

# Copy custom configuration file
COPY infra/nginx/default.conf /etc/nginx/conf.d/default.conf
ADD public /var/www/public
Brody
Brody5mo ago
may i ask why you cant run php and nginx in the same container?
Karthick K
Karthick K5mo ago
i am planning for a load balncer config so i need to run cron job and queue using the same code but different containers do you think nginx:stable-alpine is a problem here ?
Karthick K
Karthick K5mo ago
changing it to nginx fixed
Brody
Brody5mo ago
all solved?
Karthick K
Karthick K5mo ago
yes
Brody
Brody5mo ago
awesome