R
Railwayā€¢16mo ago
Medim

Issues using Nginx to reverse proxy

Hey there! I'm in the process of migrating some of my company projects to Railway but i'm having some issues setting up PHP-FPM. PHP-FPM needs a nginx reverse proxy with Fastcgi to be able to serve files. Ok... I did that! My PHP-FPM is live and accepting connections, I generated a domain and directed Nginx to it. My API also is able to reach Nginx just fine. The flow is simple: API -> NGINX -> PHP-FPM API But currently, all my requests time out at the PHP-FPM API. Log from Nginx:
2023/03/20 18:12:05 [error] 30#30: *23 upstream timed out (110: Connection timed out) while connecting to upstream, client: 192.168.0.4, server: safe-branch-production.up.railway.app, request: "POST /nfe/valid/nfce HTTP/1.1", upstream: "fastcgi://104.196.232.237:9000", host: "safe-branch-production.up.railway.app"
192.168.0.4 - - [20/Mar/2023:18:12:05 +0000] "POST /nfe/valid/nfce HTTP/1.1" 504 167 "-" "axios/0.19.2" "34.127.13.232"
2023/03/20 18:12:05 [error] 30#30: *23 upstream timed out (110: Connection timed out) while connecting to upstream, client: 192.168.0.4, server: safe-branch-production.up.railway.app, request: "POST /nfe/valid/nfce HTTP/1.1", upstream: "fastcgi://104.196.232.237:9000", host: "safe-branch-production.up.railway.app"
192.168.0.4 - - [20/Mar/2023:18:12:05 +0000] "POST /nfe/valid/nfce HTTP/1.1" 504 167 "-" "axios/0.19.2" "34.127.13.232"
This is my default.conf file:
server {
listen 8080;
server_name safe-branch-production.up.railway.app;
root /var/www/html;
# pass the PHP scripts to FastCGI server

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

location ~ \.php$ {
fastcgi_pass gerenciei-api-nfe-production.up.railway.app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8080;
server_name safe-branch-production.up.railway.app;
root /var/www/html;
# pass the PHP scripts to FastCGI server

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

location ~ \.php$ {
fastcgi_pass gerenciei-api-nfe-production.up.railway.app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
(I will regenerate domains after this get fixed so no worries) What could it be?
279 Replies
Percy
Percyā€¢16mo ago
Project ID: de7aa210-2a7c-457e-9476-6c30744f4f10
Percy
Percyā€¢16mo ago
Medim
Medimā€¢16mo ago
de7aa210-2a7c-457e-9476-6c30744f4f10
Brody
Brodyā€¢16mo ago
you have the fast-php server running in a different service?
Medim
Medimā€¢16mo ago
Yes.
Brody
Brodyā€¢16mo ago
not ideal, don't even know if that variable allows specifying a domian
Medim
Medimā€¢16mo ago
Wait... wdym? the PHP-FPM API is the php server
Brody
Brodyā€¢16mo ago
not to mention you are trying to connect to it over port 9000 when at the moment you can only connect to a railway app over 443 and web traffic only nginx and fast-cgi or php-fpm or whatever it's called should both be running in the same service and communication should be done over a socket
Medim
Medimā€¢16mo ago
Was just testing things, I will put that var there again
Brody
Brodyā€¢16mo ago
railway won't proxy non web traffic anyway besides I have never seen nginx and php be in separate services, I can't imagine that's good for latency
Medim
Medimā€¢16mo ago
So the best option here is to put them in the same service
Brody
Brodyā€¢16mo ago
yes and communicate over a socket of course you could do what you wanted when railway has internal networking, but they don't yet, so nginx and php should go into the same container
Medim
Medimā€¢16mo ago
Is it possible to put the two together on one service in railway? With separate dockerfiles? otherwise im gonna build a linux img with the two
Brody
Brodyā€¢16mo ago
you are building with a dockerfile right?
Medim
Medimā€¢16mo ago
Yeah, on aws it was two separated docker files.
####
FROM php:7.4-fpm as phpfpm
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
zlib1g-dev \
libzip-dev \
libjpeg-dev \
libxml2-dev \
libonig-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install soap zip

# Copy PHP files
COPY . /var/www/html/

# Expose and start PHP-FPM
EXPOSE 9000
CMD ["php-fpm"]
####
FROM php:7.4-fpm as phpfpm
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
zlib1g-dev \
libzip-dev \
libjpeg-dev \
libxml2-dev \
libonig-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install soap zip

# Copy PHP files
COPY . /var/www/html/

# Expose and start PHP-FPM
EXPOSE 9000
CMD ["php-fpm"]
and the nginx one:
FROM nginx:1.20 as nginx

COPY default.conf /etc/nginx/conf.d/default.conf

WORKDIR /var/www/html

EXPOSE 80
FROM nginx:1.20 as nginx

COPY default.conf /etc/nginx/conf.d/default.conf

WORKDIR /var/www/html

EXPOSE 80
Brody
Brodyā€¢16mo ago
yep you'll want to combine your two dockerfiles since railway doesn't have internal networking yet
Medim
Medimā€¢16mo ago
Ok, will try that.
Brody
Brodyā€¢16mo ago
that's how nixpacks will run PHP stuff, they will have nginx and php in the same container also no need for expose in the dockerfile, just have nginx listen on $PORT
Medim
Medimā€¢16mo ago
####
FROM php:7.4-fpm as phpfpm
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
nginx \
zlib1g-dev \
libzip-dev \
libjpeg-dev \
libxml2-dev \
libonig-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install soap zip

# Copy PHP files
COPY . /var/www/html/

# Copy NGINX conf
COPY default.conf /etc/nginx/conf.d/default.conf

WORKDIR /var/www/html

# Start NGINX
RUN service nginx start

# Expose and start PHP-FPM
EXPOSE 9000
CMD ["php-fpm"]
####
FROM php:7.4-fpm as phpfpm
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
nginx \
zlib1g-dev \
libzip-dev \
libjpeg-dev \
libxml2-dev \
libonig-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install soap zip

# Copy PHP files
COPY . /var/www/html/

# Copy NGINX conf
COPY default.conf /etc/nginx/conf.d/default.conf

WORKDIR /var/www/html

# Start NGINX
RUN service nginx start

# Expose and start PHP-FPM
EXPOSE 9000
CMD ["php-fpm"]
Came up with this, gonna try it šŸ‘
Brody
Brodyā€¢16mo ago
the phpfpm image contains nginx?
Medim
Medimā€¢16mo ago
... I don't think so.
Brody
Brodyā€¢16mo ago
probably gonna need nginx lol
Medim
Medimā€¢16mo ago
would server_name and fastcgi_pass be localhost? its in the install command In aws it worked fine between 2 different services because of internal IPs?
Brody
Brodyā€¢16mo ago
oh my bad missed that yeah 127.0.0.1 or use a socket, socket > ip
Medim
Medimā€¢16mo ago
gonna try without it for now building... btw i couldn't delete the nginx-nfe service
Brody
Brodyā€¢16mo ago
for sure railway L
Medim
Medimā€¢16mo ago
'Failed to delete' šŸ’€
Brody
Brodyā€¢16mo ago
just remove the latest deployment until they fix that
Medim
Medimā€¢16mo ago
Already failed on RUN service nginx start lmao
Brody
Brodyā€¢16mo ago
does apt install register nginx as a service automatically?
Medim
Medimā€¢16mo ago
It should, gonna try running it together in CMD
Brody
Brodyā€¢16mo ago
you could also use a pre-built php-nginx image this my be helpful https://github.com/TrafeX/docker-php-nginx it uses supervisord to start both nginx and php
Medim
Medimā€¢16mo ago
Gonna take a look, im struggling to start both services gonna try one last time with a sh file kekw
Brody
Brodyā€¢16mo ago
def skill issue (jokes)
Medim
Medimā€¢16mo ago
that hurts
Medim
Medimā€¢16mo ago
nah, i agree with you DEFINETELY skill issues oh man im bad at docker
Brody
Brodyā€¢16mo ago
common php L you should look into building your docker stuff locally
Medim
Medimā€¢16mo ago
i normally do that, basic stuff uhm i guess it worked??
Brody
Brodyā€¢16mo ago
proof?
Medim
Medimā€¢16mo ago
idk about nginx
Medim
Medimā€¢16mo ago
Brody
Brodyā€¢16mo ago
script will never make it to line 3 since it waits for php-fpm to close (and it wont close)
Medim
Medimā€¢16mo ago
cryingman take a look at that img u shared
Brody
Brodyā€¢16mo ago
add an and symbol to the end of line 2
Medim
Medimā€¢16mo ago
one or two?
Brody
Brodyā€¢16mo ago
one
Medim
Medimā€¢16mo ago
#!/bin/bash
php-fpm &
nginx -g 'daemon off;' &
echo 'Started services'
#!/bin/bash
php-fpm &
nginx -g 'daemon off;' &
echo 'Started services'
Brody
Brodyā€¢16mo ago
nvm, that looks fine i think
Medim
Medimā€¢16mo ago
well, another 10 mins building
Brody
Brodyā€¢16mo ago
test building locally
Medim
Medimā€¢16mo ago
yeah..
Brody
Brodyā€¢16mo ago
your entry point should now be that bash script, dont run the batch script during build
Medim
Medimā€¢16mo ago
ayo
Medim
Medimā€¢16mo ago
i guess it cached the build
Brody
Brodyā€¢16mo ago
yay
Medim
Medimā€¢16mo ago
didn't work, going with that php-fpm-nginx img next no logs on the service either
Brody
Brodyā€¢16mo ago
prob cuz & starts the service in the background use the github repo i linked as a starting point
Finn
Finnā€¢16mo ago
you lads enjoying IsForMe deleted it an
Brody
Brodyā€¢16mo ago
well i have to go, finn will take over from here
Finn
Finnā€¢16mo ago
whats the current issue
Brody
Brodyā€¢16mo ago
op is trying to use php in 2023 that's the real issue
Finn
Finnā€¢16mo ago
lmfao (real)
Medim
Medimā€¢16mo ago
cryingman are currently trying to run php-fpm and nginx on the same dockerfile I had separate services, but the way i was doing it couldn't be possible without internal networking So now, Brody linked me this github img https://github.com/TrafeX/docker-php-nginx/tree/master/config and im trying it out to see if it works
Finn
Finnā€¢16mo ago
i wish i was of help
Medim
Medimā€¢16mo ago
You can be! Im currently experiencing excruciating paincloud hate php but unfortunately our ancient 'government tax api' is using it
Finn
Finnā€¢16mo ago
Medim
Medimā€¢16mo ago
if caddy is easier im willing to give it a shot
Brody
Brodyā€¢16mo ago
caddy definitely easier sorry I didn't just get bored helping, I had to do something else and am no longer at my computer so I can't do any real help
Medim
Medimā€¢16mo ago
np, gotta get off soon too gonna resume it tomorrow with caddy after trying that img u linked, nginx is getting on my nerves
Brody
Brodyā€¢16mo ago
caddy is definitely better than nginx, but you'll still wanna use supervisord to run both services
Ray
Rayā€¢16mo ago
Why are you running nginx? Do you need to serve static files? You don't really need nginx on Railway so I'm curious why that's a dependency It's actually not that bad! Meme aside, I've ran modern PHP workloads in k8s over tens of services and close to 300 pods, with a bunch of k8s ingress magic for nginx load-balancing. It's actually pretty awesome compared to scaling JS/node stuff because of its stability. Performance sucks though, that's why we had to run ~300 pods. Not an issue if you can scale horizontally and have money to throw at it & it doesn't matter much for small-medium scale projects Can you share your nginx conf? Your upstream is timing out so nginx can't reach it; it suggests an issue with the nginx conf on how you're proxying connections to it
Medim
Medimā€¢16mo ago
I will post it tomorrow, im bowling atm kekw
Ray
Rayā€¢16mo ago
have fun šŸ™‚
Medim
Medimā€¢16mo ago
Update: I'm using this img https://github.com/TrafeX/docker-php-nginx But theres a catch, i use docker-php-ext-configure and docker-php-ext-install commands to install some extensions. The image he provides isn't an official alpine-docker img, so it doesn't have these commands. ...I got a workaround that I'm going to try rn, i found some precompiled packages on alpine registry, it builded the img successfully
Brody
Brodyā€¢16mo ago
Optimized for 100 concurrent users lol
Medim
Medimā€¢16mo ago
Medim
Medimā€¢16mo ago
that was fast (crashed almost at the same time it got up)
Brody
Brodyā€¢16mo ago
fail fast bby
Medim
Medimā€¢16mo ago
ok so whats the caddy alternative kekw
server {
listen 8080;
server_name 127.0.0.1;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8080;
server_name 127.0.0.1;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
I don't think the time out is the problem... Because it couldn't reach the php-fpm at all.
Brody
Brodyā€¢16mo ago
https://gitlab.com/jeffam/php-fpm-caddy this looks like a good starting point
Medim
Medimā€¢16mo ago
gonna take a look looks good, official php-fpm image meaning i have the docker-php commands and its precompiled with some extensions i use, just gonna have to mess around the nginx config to caddy
Brody
Brodyā€¢16mo ago
sounds good
Medim
Medimā€¢16mo ago
actually, some guy just said to me to try https://github.com/richarvey/nginx-php-fpm so im gonna give nginx A LAST TRY
Brody
Brodyā€¢16mo ago
154 lines for a dockerfile f me
Medim
Medimā€¢16mo ago
...yep
Brody
Brodyā€¢16mo ago
jeez you trying to increase your build times???
Medim
Medimā€¢16mo ago
our php-fpm/nginx isnt something that we build frequently so i guess i don't care that much about build AUGH
Brody
Brodyā€¢16mo ago
copium
Medim
Medimā€¢16mo ago
holy shit holy shit it builded with the needed extensions
Brody
Brodyā€¢16mo ago
how long take?
Medim
Medimā€¢16mo ago
68.5s
Brody
Brodyā€¢16mo ago
okay thats fast af for what it is
Medim
Medimā€¢16mo ago
on my pretty bad work computer
Medim
Medimā€¢16mo ago
omg no errors!
Medim
Medimā€¢16mo ago
KEK
Brody
Brodyā€¢16mo ago
they use supervisord like i said to yesterday also I think I might have to kick you light mode??????
Medim
Medimā€¢16mo ago
...does docker have dark mode? lmao omg it does
Brody
Brodyā€¢16mo ago
switch this instance
Medim
Medimā€¢16mo ago
So, uhm Got a question
Brody
Brodyā€¢16mo ago
yeah?
Medim
Medimā€¢16mo ago
server {
listen 8080;
server_name 127.0.0.1;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8080;
server_name 127.0.0.1;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
In the 'listen 8080' i get it that i will reach the nginx with this port, but what about the fastcgi pass? what that port does cause i can't see on my code where i define it lmao
Brody
Brodyā€¢16mo ago
well what port does the config in that repo use? they don't, they used a socket, like I also told you to use lol
Medim
Medimā€¢16mo ago
cryingman
Brody
Brodyā€¢16mo ago
typical user not listening to conductors (jokes)
Medim
Medimā€¢16mo ago
seems like 9000 is the default fastcgi port, you can use a socket too but im too dumb to use it, really.
Brody
Brodyā€¢16mo ago
just look at how the repo uses the socket, and use it the same way
Medim
Medimā€¢16mo ago
yeah
Brody
Brodyā€¢16mo ago
socket is funny word
Medim
Medimā€¢16mo ago
can't reach any endpoint cryingman its not even hitting that API now time to debug
Brody
Brodyā€¢16mo ago
is nginx set to listen on $PORT?
Medim
Medimā€¢16mo ago
yep.
Brody
Brodyā€¢16mo ago
what status code do you get?
Medim
Medimā€¢16mo ago
400 "connect EINVAL 0.0.31.144:80 - Local (0.0.0.0:0)"
Brody
Brodyā€¢16mo ago
bad request hmmm are you sure nginx is connecting to php?
Medim
Medimā€¢16mo ago
idk... i cant even acess nginx it doesnt log anything, testing on local
Brody
Brodyā€¢16mo ago
odd caddy when? nginx is mid anyways
Medim
Medimā€¢16mo ago
cryingman was so close... so close......
Brody
Brodyā€¢16mo ago
yet so far
Medim
Medimā€¢16mo ago
Config Adapters - Caddy Documentation
Caddy is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go
Medim
Medimā€¢16mo ago
ohh i guess i can just convert my conf
Brody
Brodyā€¢16mo ago
I forgot about that
Medim
Medimā€¢16mo ago
but im still bothered by how im unable to hit even the nginx endpoint šŸ˜­ nvm
Brody
Brodyā€¢16mo ago
well you must be hitting something since some type of web server is returning the 400
Ray
Rayā€¢16mo ago
hey sorry I missed the ping here, will check back in 30mins!
Medim
Medimā€¢16mo ago
dw @Brody the img u linked didn't work, could pull/build from that repo (idk why lol) so i found this one https://hub.docker.com/r/skiychan/caddy-php already ran it, just trying to figure how can i convert my conf and run with that conf
Ray
Rayā€¢16mo ago
@Medim why do you need a reverse proxy? The nixpacks build should work if you're hosting an fpm application
Medim
Medimā€¢16mo ago
not if you use php extensions
Ray
Rayā€¢16mo ago
gotcha, taking a look now!
Medim
Medimā€¢16mo ago
PHP extensions have some lib dependencies, idk how nixpacks will handle that lol
Ray
Rayā€¢16mo ago
Dockerfile:
FROM php:7.4-fpm as base
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
nginx \
supervisor \
zlib1g-dev \
libzip-dev \
libjpeg-dev \
libxml2-dev \
libonig-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev
RUN docker-php-ext-install gd soap zip
RUN docker-php-ext-configure gd --with-freetype --with-jpeg

FROM base as config
COPY default.conf /etc/nginx/conf.d/default.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

FROM config as app
WORKDIR /var/www/html
COPY . .
CMD ["/usr/bin/supervisord"]
FROM php:7.4-fpm as base
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
nginx \
supervisor \
zlib1g-dev \
libzip-dev \
libjpeg-dev \
libxml2-dev \
libonig-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev
RUN docker-php-ext-install gd soap zip
RUN docker-php-ext-configure gd --with-freetype --with-jpeg

FROM base as config
COPY default.conf /etc/nginx/conf.d/default.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

FROM config as app
WORKDIR /var/www/html
COPY . .
CMD ["/usr/bin/supervisord"]
supervisord.conf (place this in your root directory/same as Dockerfile):
[supervisord]
nodaemon=true

[program:nginx]
command=nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[supervisord]
nodaemon=true

[program:nginx]
command=nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
Nginx conf (default.conf):
server {
listen 8080;
server_name 0.0.0.0;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8080;
server_name 0.0.0.0;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
Nginx is configured to listen on 8080 and proxies to fpm running on port 9000. You'll need to set the PORT service variable in Railway to 8080 so it can reach your Nginx. Example: https://ruddy-wing-production.up.railway.app/public/index.php
...

[REMOTE_ADDR] => 192.168.0.4
[SERVER_SOFTWARE] => nginx/1.18.0
[GATEWAY_INTERFACE] => CGI/1.1
...
...

[REMOTE_ADDR] => 192.168.0.4
[SERVER_SOFTWARE] => nginx/1.18.0
[GATEWAY_INTERFACE] => CGI/1.1
...
šŸ™‚
Medim
Medimā€¢16mo ago
..holy shit
Ray
Rayā€¢16mo ago
it uses supervisor to run fpm and nginx in the same container
Medim
Medimā€¢16mo ago
building it, one sec
Ray
Rayā€¢16mo ago
I'll take a look at that
Brody
Brodyā€¢16mo ago
id stay away from nixpacks with a config like this anyway
Medim
Medimā€¢16mo ago
...deploying
Brody
Brodyā€¢16mo ago
nixpacks is scary dockerfile is warm and comfy
Medim
Medimā€¢16mo ago
soo many trouble for building an api that is rebuilt every 1-2 year lol
Brody
Brodyā€¢16mo ago
rewrite it in COBOL
Medim
Medimā€¢16mo ago
so to make sure im not screwing anything over after its deployed, i get its domain and put on my API vars gerenciei-api-nfe-production.up.railway.app:8080 right? with or without the ports? since railway uses it
Brody
Brodyā€¢16mo ago
without but if you use a port other than $PORT you will have to define PORT in the service variables
Medim
Medimā€¢16mo ago
kk basically it redirects the default port to the one defined in $PORT right?
Brody
Brodyā€¢16mo ago
443 goes to 8080
Medim
Medimā€¢16mo ago
yeah
Brody
Brodyā€¢16mo ago
as long as you set the service variable PORT to 8080
Medim
Medimā€¢16mo ago
it confuses me this port like EXPOSE and ports in docker are different things
Brody
Brodyā€¢16mo ago
render and heroku have auto detection systems that will detect the port the app is running on and redeploy with the correct port set for you, I wonder when railway will have something like this you don't need expose in a dockerfile at least the ones you run on railway
Medim
Medimā€¢16mo ago
railway already does this? no? to front end apps or something like that
Brody
Brodyā€¢16mo ago
rc's dockerfile doesn't have expose
Medim
Medimā€¢16mo ago
connect ECONNREFUSED 127.0.0.1:80 F
Brody
Brodyā€¢16mo ago
not at all, that's why there's so many questions "I'm getting server error"
Medim
Medimā€¢16mo ago
i guess thats from the default conf
Brody
Brodyā€¢16mo ago
what is giving that error none of the provided config files from rc use a port 80?
Medim
Medimā€¢16mo ago
Medim
Medimā€¢16mo ago
server {
listen 8080;
server_name 0.0.0.0;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8080;
server_name 0.0.0.0;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri $uri/ /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
comes from default.conf
Brody
Brodyā€¢16mo ago
there's no PORT 80?
Medim
Medimā€¢16mo ago
no lol
Brody
Brodyā€¢16mo ago
so where that error coming from rc's demo worked, so what are you changing from his config files?
Medim
Medimā€¢16mo ago
absolutely nothing
Brody
Brodyā€¢16mo ago
I'm tempted to deploy his config files and show you they work, but I'm on mobile
Medim
Medimā€¢16mo ago
no ports
Medim
Medimā€¢16mo ago
where is that 80 coming from....
Brody
Brodyā€¢16mo ago
can you access that url from the browser? domain*
Ray
Rayā€¢16mo ago
where are you getting the 80? Do you have a service variable set for PORT to 8080?
Medim
Medimā€¢16mo ago
yeah, it goes to the 403 forbidden
Ray
Rayā€¢16mo ago
I don't think you need to expose the port in docker at all when running them through supervisor. The processes will expose themselves definitely an nginx conf issue, then šŸ™‚ try browsing to /public/index.php? I didn't modify your nginx conf besides the host/port
Medim
Medimā€¢16mo ago
HTTP ERROR 500 getting some weird php errors on the logs gonna try something, one sec. Actually, when i get to that domain, it tries to serve the index.php file but errors out DIR in my code is somehow pointing to the wrong folder ... but it doesnt happen locally
Ray
Rayā€¢16mo ago
locally with nginx+fpm too?
Medim
Medimā€¢16mo ago
it still errors out as 405 on my local docker and on railway it throws an error 500
Medim
Medimā€¢16mo ago
yep, same img oh yeah, composer is missing in the img
Ray
Rayā€¢16mo ago
ah yeah, looks like you're not building your app dependencies in the image
Medim
Medimā€¢16mo ago
RUN curl -sSL https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer

RUN composer install
RUN curl -sSL https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer

RUN composer install
added this to the dockerfile, gonna try it
Ray
Rayā€¢16mo ago
composer install will install the dependencies into a vendor directory - you'll likely need to copy that into your app's directory
Medim
Medimā€¢16mo ago
wdym? It justs needs the composer.json to function nvm, composer got its own img so im gonna multi stage it
Brody
Brodyā€¢16mo ago
you're definitely over thinking this
Medim
Medimā€¢16mo ago
yeah
Brody
Brodyā€¢16mo ago
you said you modified rc's nginx config file? why? his demo worked fine
Medim
Medimā€¢16mo ago
I didnt modify it everything was the same, now im modifying his dockerfile cause it wasnt installing the packages
Medim
Medimā€¢16mo ago
composer packages šŸ‘Œ still 405 tho
Medim
Medimā€¢16mo ago
same thing... how can it be this weird port...
Medim
Medimā€¢16mo ago
well, gonna continue tomorrow. I've been 8+ hours on this today really appreciate you guys help
Ray
Rayā€¢16mo ago
are you hardcoding the connection in your frontend by any chance? have a good rest šŸ™‚ I can take a deeper look if you share your code/repo
Medim
Medimā€¢16mo ago
This request is made on my expressjs api to this second php api, its all on env vars so it shouldnā€™t be hardcoded but i guess i will need to debug it tomorrow
Medim
Medimā€¢16mo ago
logged that apiNfeUrl before using it
Medim
Medimā€¢16mo ago
I literally have no clue where that 127.0.0.1 come from
Brody
Brodyā€¢16mo ago
okay slow tf down get a simple info php script running first, like in mine or rc's examples
Medim
Medimā€¢16mo ago
https://gerenciei-api-nfe-production.up.railway.app/public/index.php strange, cause https://gerenciei-api-nfe-production.up.railway.app/ is hitting that index.php too but it gives a 403 on the frond end but a 200 on the log šŸ’€
Brody
Brodyā€¢16mo ago
Medim
Medimā€¢16mo ago
I can fix that by adjusting the defautl conf root param from /var/www/html to /var/www/html/public/index.php
angelo
angeloā€¢16mo ago
Medim, I will pay good hard Railway credits if you PR a PHP section to the Railway docs with common workarounds for PHP projects.
Medim
Medimā€¢16mo ago
Hi Angelo! Honestly, you're asking the wrong guy for this. I hate PHP
Brody
Brodyā€¢16mo ago
lmfao x400
Medim
Medimā€¢16mo ago
cryingman
angelo
angeloā€¢16mo ago
by hating PHP, that only makes you a better writer
Medim
Medimā€¢16mo ago
4 days already trying to fix this issue im having
angelo
angeloā€¢16mo ago
PHP > lambo doesn't happen without a little bit of pain
Medim
Medimā€¢16mo ago
But sure, when i get this thing to work i can compile a little bit of my knowledge in php to the railway docs
Brody
Brodyā€¢16mo ago
i cant stop laughing
Medim
Medimā€¢16mo ago
brody... i was thinking fast-cgi, uses this combination of file (index.php) + args
Brody
Brodyā€¢16mo ago
paraphrasing A: i will pay you for expanding the php docs m: i hate php
Medim
Medimā€¢16mo ago
what if i change my baseUrl to .../public/index.php since im not hiting it at the root level kekw
Brody
Brodyā€¢16mo ago
this is what i did maybe
Medim
Medimā€¢16mo ago
but u mean at root level? cause u arent doing it in the url .
Brody
Brodyā€¢16mo ago
location / {
try_files $uri /index.php?$query_string;
}
location / {
try_files $uri /index.php?$query_string;
}
this is mine
Medim
Medimā€¢16mo ago
... gonna try that
Brody
Brodyā€¢16mo ago
hold on
Medim
Medimā€¢16mo ago
holding
Brody
Brodyā€¢16mo ago
i have a folder in my project named src and in that folder i have my index.php then in my dockerfile i have
WORKDIR /var/www/html

ADD /src .
WORKDIR /var/www/html

ADD /src .
Medim
Medimā€¢16mo ago
i dont have a src folder, everything is at root level except index.php that is served in a public/index.php dir will try something again btw, the error now changed https://gerenciei-api-nfe-production.up.railway.app/public/index.php a method error
Brody
Brodyā€¢16mo ago
the only thing thats in my src folder is index.php all config files are in project root
Medim
Medimā€¢16mo ago
Mine too, it just serves from another folder, i will try something building... https://gerenciei-api-nfe-production.up.railway.app/ yeah that didnt work
Brody
Brodyā€¢16mo ago
why not
Brody
Brodyā€¢16mo ago
Medim
Medimā€¢16mo ago
cause that isnt my index.php file... i dont know where that hello world is coming kekw
$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write('Hello world!');
return $response;
});
$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write('Hello world!');
return $response;
});
THATS THE DEFAULT ROUTE
Brody
Brodyā€¢16mo ago
lmfao
Medim
Medimā€¢16mo ago
the 405 errors im getting are actually from the PHP-SLIM framework im using and now my frontend is hitting the api as it should
Medim
Medimā€¢16mo ago
Medim
Medimā€¢16mo ago
now i need to know why is it erroring like that cryingman
Brody
Brodyā€¢16mo ago
what even is this error dialog
Medim
Medimā€¢16mo ago
just a debug one, normally here we translate errors to the user like: 'Tax information from product 1 is incorrect' or something like that
Brody
Brodyā€¢16mo ago
are you able to access index.php from the root yet?
Medim
Medimā€¢16mo ago
yep
Brody
Brodyā€¢16mo ago
yay
Medim
Medimā€¢16mo ago
it redirects me to the routes, that what it is supposed to do and it hits this default rote just need to know why other routes are giving me 405
Brody
Brodyā€¢16mo ago
supervisord isnt forwarding error prints to stderr whenever you got a 403 in the browser, would you see a 403 in the deploy logs?
Medim
Medimā€¢16mo ago
im using a static route here that we have it gives a 200 followed by a 405 Im able to see its content, but it throws a 405 at the log right thonk
Brody
Brodyā€¢16mo ago
you need some verbose logs or something lol
Medim
Medimā€¢16mo ago
i think thats the best slim-php can do really lmao
Brody
Brodyā€¢16mo ago
common php L
Brody
Brodyā€¢16mo ago
did you provide a token?
Medim
Medimā€¢16mo ago
...yes
Brody
Brodyā€¢16mo ago
in what form query param, header, body?
Medim
Medimā€¢16mo ago
Brody
Brodyā€¢16mo ago
very possible, i know some frameworks wont clean the url
Medim
Medimā€¢16mo ago
i guess this one doesnt, thats why its giving 405 all over ..oh i got it
Brody
Brodyā€¢16mo ago
ideally the framework would return 404 on a malformed path, but slim wants to return 405 ig
Medim
Medimā€¢16mo ago
this one was my bad, left the api var with a / at the end needed to use the https url for some reason, without it wasnt hitting the api
Brody
Brodyā€¢16mo ago
its always user error (joke) def need https scheme
Medim
Medimā€¢16mo ago
well.. redeploying it worked flawlessly
Brody
Brodyā€¢16mo ago
I'm so smort (he lied)
Medim
Medimā€¢16mo ago
all i needed to do was change the try_files url on the default.conf
server {
listen 8080;
server_name 0.0.0.0;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8080;
server_name 0.0.0.0;
root /var/www/html;
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000

location / {
try_files $uri /public/index.php?q=$uri&$args;
}

# comment vv
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
Well, thank you guys
Brody
Brodyā€¢16mo ago
bro wouldn't listen to me
Medim
Medimā€¢16mo ago
lmao
Brody
Brodyā€¢16mo ago
tsk tsk tsk
Medim
Medimā€¢16mo ago
thanks @Brody and @rc you two were of great help and thanks @Finn - uses centos for the emotional support lmfao
Brody
Brodyā€¢16mo ago
what so everything works?
Medim
Medimā€¢16mo ago
hope this 300+ msgs thread can help someone else so far, yes. I will post some workarounds for php on the railway docs too
Medim
Medimā€¢16mo ago
just wanted to delete this ghost service but seems i'm unable to kekw
Brody
Brodyā€¢16mo ago
what errors do you get?
Ray
Rayā€¢16mo ago
I think the core issue here is you shouldn't need to add a reverse proxy.. It should just work with nixpacks on Railway (so Railway's proxy talks to fpm directly, instead of nginx), but it doesn't with some PHP extensions (?), so I'd like to dig into it and make it work. I'll replicate this on nixpacks and see if I can get it working with the extensions that OP needs, so in the future there's no need for anyone to run a reverse proxy along with php.
Medim
Medimā€¢16mo ago
"Failed to delete"
Brody
Brodyā€¢16mo ago
have you refreshed the page?
Medim
Medimā€¢16mo ago
Medim
Medimā€¢16mo ago
many times
Brody
Brodyā€¢16mo ago
rip wait it out
Medim
Medimā€¢16mo ago
{ "message": "Not Authorized", "locations": [ { "line": 2, "column": 3 } ], "path": [ "serviceDelete" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "exception": { "status": 400 } } }
Brody
Brodyā€¢16mo ago
funky don't really know what to tell you
Medim
Medimā€¢16mo ago
its triggering my ocd fix AUGH
Brody
Brodyā€¢16mo ago
I do not have such power two other people just reported issues with the API, you're not alone
Medim
Medimā€¢16mo ago
I get that, but its dependable on the framework/packages the php project is using, isn't it? Idk how to manage that since some packages also needs specific libs thonk been trying to delete that for 2 days now
Brody
Brodyā€¢16mo ago
that's not good
Ray
Rayā€¢16mo ago
yeah that's why I wanna figure it out šŸ™‚ usually with php extensions, you just need to pecl install it into the runtime. It'd be nice to have nixpacks work with a bunch of common php extensions. https://github.com/railwayapp/nixpacks/pull/829 seems relevant to this. @Medim can I have your composer.json?
Medim
Medimā€¢16mo ago
Sure, one sec.
{
"name": "slim/slim-skeleton",
"description": "A Slim Framework skeleton application for rapid development",
"keywords": [
"microframework",
"rest",
"router",
"psr7"
],
"homepage": "http://github.com/slimphp/Slim-Skeleton",
"license": "MIT",
"authors": [
{
"name": "Josh Lockhart",
"email": "info@joshlockhart.com",
"homepage": "http://www.joshlockhart.com/"
},
{
"name": "Pierre Berube",
"email": "pierre@lgse.com",
"homepage": "http://www.lgse.com/"
}
],
"require": {
"php": "^7.2",
"ext-json": "*",
"aws/aws-sdk-php": "^3.176",
"aws/aws-sdk-php-resources": "^0.3.0",
"monolog/monolog": "^2.2",
"nfephp-org/sped-da": "^1.0",
"nfephp-org/sped-nfe": "^5.0",
"nfephp-org/sped-pos": "dev-master",
"php-di/php-di": "^6.3",
"slim/psr7": "^1.3",
"slim/slim": "^4.7"
},
"require-dev": {
"jangregor/phpstan-prophecy": "^0.8.1",
"phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan": "^0.12.70",
"phpunit/phpunit": "^8.5"
},
"config": {
"process-timeout": 0,
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"start": "php -S 127.0.0.1:3007 -t public",
"test": "phpunit"
}
}
{
"name": "slim/slim-skeleton",
"description": "A Slim Framework skeleton application for rapid development",
"keywords": [
"microframework",
"rest",
"router",
"psr7"
],
"homepage": "http://github.com/slimphp/Slim-Skeleton",
"license": "MIT",
"authors": [
{
"name": "Josh Lockhart",
"email": "info@joshlockhart.com",
"homepage": "http://www.joshlockhart.com/"
},
{
"name": "Pierre Berube",
"email": "pierre@lgse.com",
"homepage": "http://www.lgse.com/"
}
],
"require": {
"php": "^7.2",
"ext-json": "*",
"aws/aws-sdk-php": "^3.176",
"aws/aws-sdk-php-resources": "^0.3.0",
"monolog/monolog": "^2.2",
"nfephp-org/sped-da": "^1.0",
"nfephp-org/sped-nfe": "^5.0",
"nfephp-org/sped-pos": "dev-master",
"php-di/php-di": "^6.3",
"slim/psr7": "^1.3",
"slim/slim": "^4.7"
},
"require-dev": {
"jangregor/phpstan-prophecy": "^0.8.1",
"phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan": "^0.12.70",
"phpunit/phpunit": "^8.5"
},
"config": {
"process-timeout": 0,
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"start": "php -S 127.0.0.1:3007 -t public",
"test": "phpunit"
}
}
Ray
Rayā€¢16mo ago
thanks!
Medim
Medimā€¢16mo ago
np
Ray
Rayā€¢16mo ago
railway up works for me using the composer.json with ext-json removed from require
Medim
Medimā€¢16mo ago
ext-json is an essential extension for our api to run cryingman
Brody
Brodyā€¢16mo ago
pin it to a specific version?
Ray
Rayā€¢16mo ago
ext-json is included in >php8, there's no need to install it
Medim
Medimā€¢16mo ago
but at lower versions of php? for example we use 7.4 can't it be added as a NXPKG or something like that
Ray
Rayā€¢16mo ago
I don't think nixpacks support that specific php version šŸ˜• your composer requires php^7.2, so nixpacks will build using >8
Medim
Medimā€¢16mo ago
Yeah, but if it works at php8 thats perfect. We will upgrade to it soon.
Ray
Rayā€¢16mo ago
and then you can get rid of the Dockerfile+supervisor/nginx conf šŸ„³
avtomonov
avtomonovā€¢12mo ago
Hello, I have 2 services: fastAPI backend and nginx frontend serving as reverse proxy. It works fine when backend starts first and then the frontend, however in the opposite case (for example after a git push backend takes longer to start) Nginx keeps failing with
2023/07/27 23:01:54 [error] 10#10: *83 upstream timed out (110: Connection timed out) while connecting to upstream, client: 192.168.0.2, server: , request: "GET /api/data HTTP/1.1", upstream: "http://[fd12:a13d:e0aa::2:937d:2da]:8000/api/data", host: "..."
2023/07/27 23:01:54 [error] 10#10: *83 upstream timed out (110: Connection timed out) while connecting to upstream, client: 192.168.0.2, server: , request: "GET /api/data HTTP/1.1", upstream: "http://[fd12:a13d:e0aa::2:937d:2da]:8000/api/data", host: "..."
any idea why it could be happening? Here's my nginx config:
error_log stderr info;
pid "${GSK_HOME}/run/nginx/nginx.pid";
daemon off;
working_directory "${GSK_HOME}/run/nginx";

events {
worker_connections 1024;
}

http {
gzip on;
gzip_types text/javascript application/json text/css image/svg+xml;
client_max_body_size 0;
large_client_header_buffers 8 64k;

include /etc/nginx/mime.types;

access_log /dev/stdout;
error_log /dev/stdout;

client_body_temp_path "${GSK_HOME}/run/nginx";
proxy_temp_path "${GSK_HOME}/run/nginx";


proxy_http_version 1.1;
proxy_read_timeout 3600;

proxy_redirect off;
proxy_next_upstream off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

resolver [fd12::10] valid=10s;
proxy_intercept_errors off;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $server_name;

server {
listen 7860;
listen [::]:7860;
root ${GSK_DIST_PATH}/frontend/dist;

location / {
try_files $uri $uri/ /index.html;
}

location /api {
client_max_body_size 16G;
proxy_pass http://${GSK_BACKEND_HOST}:${GSK_BACKEND_PORT};

proxy_connect_timeout 70s;
proxy_send_timeout 86400;
proxy_read_timeout 86400;
send_timeout 86400;
}

}
}
error_log stderr info;
pid "${GSK_HOME}/run/nginx/nginx.pid";
daemon off;
working_directory "${GSK_HOME}/run/nginx";

events {
worker_connections 1024;
}

http {
gzip on;
gzip_types text/javascript application/json text/css image/svg+xml;
client_max_body_size 0;
large_client_header_buffers 8 64k;

include /etc/nginx/mime.types;

access_log /dev/stdout;
error_log /dev/stdout;

client_body_temp_path "${GSK_HOME}/run/nginx";
proxy_temp_path "${GSK_HOME}/run/nginx";


proxy_http_version 1.1;
proxy_read_timeout 3600;

proxy_redirect off;
proxy_next_upstream off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

resolver [fd12::10] valid=10s;
proxy_intercept_errors off;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $server_name;

server {
listen 7860;
listen [::]:7860;
root ${GSK_DIST_PATH}/frontend/dist;

location / {
try_files $uri $uri/ /index.html;
}

location /api {
client_max_body_size 16G;
proxy_pass http://${GSK_BACKEND_HOST}:${GSK_BACKEND_PORT};

proxy_connect_timeout 70s;
proxy_send_timeout 86400;
proxy_read_timeout 86400;
send_timeout 86400;
}

}
}
LaCrak27
LaCrak27ā€¢12mo ago
Ok this is real nice
Brody
Brodyā€¢12mo ago
hey, I'd be happy to help, and I may even have the perfect template for you, but do you think you could open your own help thread?
avtomonov
avtomonovā€¢12mo ago
sure, thanks, will do now