R
Railwayā€¢2y 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ā€¢2y ago
Project ID: de7aa210-2a7c-457e-9476-6c30744f4f10
Percy
Percyā€¢2y ago
Medim
MedimOPā€¢2y ago
de7aa210-2a7c-457e-9476-6c30744f4f10
Brody
Brodyā€¢2y ago
you have the fast-php server running in a different service?
Medim
MedimOPā€¢2y ago
Yes.
Brody
Brodyā€¢2y ago
not ideal, don't even know if that variable allows specifying a domian
Medim
MedimOPā€¢2y ago
Wait... wdym? the PHP-FPM API is the php server
Brody
Brodyā€¢2y 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
MedimOPā€¢2y ago
Was just testing things, I will put that var there again
Brody
Brodyā€¢2y 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
MedimOPā€¢2y ago
So the best option here is to put them in the same service
Brody
Brodyā€¢2y 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
MedimOPā€¢2y 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ā€¢2y ago
you are building with a dockerfile right?
Medim
MedimOPā€¢2y 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ā€¢2y ago
yep you'll want to combine your two dockerfiles since railway doesn't have internal networking yet
Medim
MedimOPā€¢2y ago
Ok, will try that.
Brody
Brodyā€¢2y 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
MedimOPā€¢2y 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ā€¢2y ago
the phpfpm image contains nginx?
Medim
MedimOPā€¢2y ago
... I don't think so.
Brody
Brodyā€¢2y ago
probably gonna need nginx lol
Medim
MedimOPā€¢2y 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ā€¢2y ago
oh my bad missed that yeah 127.0.0.1 or use a socket, socket > ip
Medim
MedimOPā€¢2y ago
gonna try without it for now building... btw i couldn't delete the nginx-nfe service
Brody
Brodyā€¢2y ago
for sure railway L
Medim
MedimOPā€¢2y ago
'Failed to delete' šŸ’€
Brody
Brodyā€¢2y ago
just remove the latest deployment until they fix that
Medim
MedimOPā€¢2y ago
Already failed on RUN service nginx start lmao
Brody
Brodyā€¢2y ago
does apt install register nginx as a service automatically?
Medim
MedimOPā€¢2y ago
It should, gonna try running it together in CMD
Brody
Brodyā€¢2y 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
MedimOPā€¢2y ago
Gonna take a look, im struggling to start both services gonna try one last time with a sh file kekw
Brody
Brodyā€¢2y ago
def skill issue (jokes)
Medim
MedimOPā€¢2y ago
that hurts
Medim
MedimOPā€¢2y ago
nah, i agree with you DEFINETELY skill issues oh man im bad at docker
Brody
Brodyā€¢2y ago
common php L you should look into building your docker stuff locally
Medim
MedimOPā€¢2y ago
i normally do that, basic stuff uhm i guess it worked??
Brody
Brodyā€¢2y ago
proof?
Medim
MedimOPā€¢2y ago
idk about nginx
Medim
MedimOPā€¢2y ago
Brody
Brodyā€¢2y ago
script will never make it to line 3 since it waits for php-fpm to close (and it wont close)
Medim
MedimOPā€¢2y ago
cryingman take a look at that img u shared
Brody
Brodyā€¢2y ago
add an and symbol to the end of line 2
Medim
MedimOPā€¢2y ago
one or two?
Brody
Brodyā€¢2y ago
one
Medim
MedimOPā€¢2y 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ā€¢2y ago
nvm, that looks fine i think
Medim
MedimOPā€¢2y ago
well, another 10 mins building
Brody
Brodyā€¢2y ago
test building locally
Medim
MedimOPā€¢2y ago
yeah..
Brody
Brodyā€¢2y ago
your entry point should now be that bash script, dont run the batch script during build
Medim
MedimOPā€¢2y ago
ayo
Medim
MedimOPā€¢2y ago
i guess it cached the build
Brody
Brodyā€¢2y ago
yay
Medim
MedimOPā€¢2y ago
didn't work, going with that php-fpm-nginx img next no logs on the service either
Brody
Brodyā€¢2y ago
prob cuz & starts the service in the background use the github repo i linked as a starting point
Finn
Finnā€¢2y ago
you lads enjoying IsForMe deleted it an
Brody
Brodyā€¢2y ago
well i have to go, finn will take over from here
Finn
Finnā€¢2y ago
whats the current issue
Brody
Brodyā€¢2y ago
op is trying to use php in 2023 that's the real issue
Finn
Finnā€¢2y ago
lmfao (real)
Medim
MedimOPā€¢2y 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ā€¢2y ago
i wish i was of help
Medim
MedimOPā€¢2y ago
You can be! Im currently experiencing excruciating paincloud hate php but unfortunately our ancient 'government tax api' is using it
Finn
Finnā€¢2y ago
Medim
MedimOPā€¢2y ago
if caddy is easier im willing to give it a shot
Brody
Brodyā€¢2y 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
MedimOPā€¢2y 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ā€¢2y ago
caddy is definitely better than nginx, but you'll still wanna use supervisord to run both services
Ray
Rayā€¢2y 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
MedimOPā€¢2y ago
I will post it tomorrow, im bowling atm kekw
Ray
Rayā€¢2y ago
have fun šŸ™‚
Medim
MedimOPā€¢2y 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ā€¢2y ago
Optimized for 100 concurrent users lol
Medim
MedimOPā€¢2y ago
Medim
MedimOPā€¢2y ago
that was fast (crashed almost at the same time it got up)
Brody
Brodyā€¢2y ago
fail fast bby
Medim
MedimOPā€¢2y 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ā€¢2y ago
https://gitlab.com/jeffam/php-fpm-caddy this looks like a good starting point
Medim
MedimOPā€¢2y 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ā€¢2y ago
sounds good
Medim
MedimOPā€¢2y 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ā€¢2y ago
154 lines for a dockerfile f me
Medim
MedimOPā€¢2y ago
...yep
Brody
Brodyā€¢2y ago
jeez you trying to increase your build times???
Medim
MedimOPā€¢2y 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ā€¢2y ago
copium
Medim
MedimOPā€¢2y ago
holy shit holy shit it builded with the needed extensions
Brody
Brodyā€¢2y ago
how long take?
Medim
MedimOPā€¢2y ago
68.5s
Brody
Brodyā€¢2y ago
okay thats fast af for what it is
Medim
MedimOPā€¢2y ago
on my pretty bad work computer
Medim
MedimOPā€¢2y ago
omg no errors!
Medim
MedimOPā€¢2y ago
KEK
Brody
Brodyā€¢2y ago
they use supervisord like i said to yesterday also I think I might have to kick you light mode??????
Medim
MedimOPā€¢2y ago
...does docker have dark mode? lmao omg it does
Brody
Brodyā€¢2y ago
switch this instance
Medim
MedimOPā€¢2y ago
So, uhm Got a question
Brody
Brodyā€¢2y ago
yeah?
Medim
MedimOPā€¢2y 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ā€¢2y 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
MedimOPā€¢2y ago
cryingman
Brody
Brodyā€¢2y ago
typical user not listening to conductors (jokes)
Medim
MedimOPā€¢2y 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ā€¢2y ago
just look at how the repo uses the socket, and use it the same way
Medim
MedimOPā€¢2y ago
yeah
Brody
Brodyā€¢2y ago
socket is funny word
Medim
MedimOPā€¢2y ago
can't reach any endpoint cryingman its not even hitting that API now time to debug
Brody
Brodyā€¢2y ago
is nginx set to listen on $PORT?
Medim
MedimOPā€¢2y ago
yep.
Brody
Brodyā€¢2y ago
what status code do you get?
Medim
MedimOPā€¢2y ago
400 "connect EINVAL 0.0.31.144:80 - Local (0.0.0.0:0)"
Brody
Brodyā€¢2y ago
bad request hmmm are you sure nginx is connecting to php?
Medim
MedimOPā€¢2y ago
idk... i cant even acess nginx it doesnt log anything, testing on local
Brody
Brodyā€¢2y ago
odd caddy when? nginx is mid anyways
Medim
MedimOPā€¢2y ago
cryingman was so close... so close......
Brody
Brodyā€¢2y ago
yet so far
Medim
MedimOPā€¢2y ago
Config Adapters - Caddy Documentation
Caddy is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go
Medim
MedimOPā€¢2y ago
ohh i guess i can just convert my conf
Brody
Brodyā€¢2y ago
I forgot about that
Medim
MedimOPā€¢2y ago
but im still bothered by how im unable to hit even the nginx endpoint šŸ˜­ nvm
Brody
Brodyā€¢2y ago
well you must be hitting something since some type of web server is returning the 400
Ray
Rayā€¢2y ago
hey sorry I missed the ping here, will check back in 30mins!
Medim
MedimOPā€¢2y 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ā€¢2y ago
@Medim why do you need a reverse proxy? The nixpacks build should work if you're hosting an fpm application
Medim
MedimOPā€¢2y ago
not if you use php extensions
Ray
Rayā€¢2y ago
gotcha, taking a look now!
Medim
MedimOPā€¢2y ago
PHP extensions have some lib dependencies, idk how nixpacks will handle that lol
Ray
Rayā€¢2y 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
MedimOPā€¢2y ago
..holy shit
Ray
Rayā€¢2y ago
it uses supervisor to run fpm and nginx in the same container
Medim
MedimOPā€¢2y ago
building it, one sec
Ray
Rayā€¢2y ago
I'll take a look at that
Brody
Brodyā€¢2y ago
id stay away from nixpacks with a config like this anyway
Medim
MedimOPā€¢2y ago
...deploying
Brody
Brodyā€¢2y ago
nixpacks is scary dockerfile is warm and comfy
Medim
MedimOPā€¢2y ago
soo many trouble for building an api that is rebuilt every 1-2 year lol
Brody
Brodyā€¢2y ago
rewrite it in COBOL
Medim
MedimOPā€¢2y 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ā€¢2y ago
without but if you use a port other than $PORT you will have to define PORT in the service variables
Medim
MedimOPā€¢2y ago
kk basically it redirects the default port to the one defined in $PORT right?
Brody
Brodyā€¢2y ago
443 goes to 8080
Medim
MedimOPā€¢2y ago
yeah
Brody
Brodyā€¢2y ago
as long as you set the service variable PORT to 8080
Medim
MedimOPā€¢2y ago
it confuses me this port like EXPOSE and ports in docker are different things
Brody
Brodyā€¢2y 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
MedimOPā€¢2y ago
railway already does this? no? to front end apps or something like that
Brody
Brodyā€¢2y ago
rc's dockerfile doesn't have expose
Medim
MedimOPā€¢2y ago
connect ECONNREFUSED 127.0.0.1:80 F
Brody
Brodyā€¢2y ago
not at all, that's why there's so many questions "I'm getting server error"
Medim
MedimOPā€¢2y ago
i guess thats from the default conf
Brody
Brodyā€¢2y ago
what is giving that error none of the provided config files from rc use a port 80?
Medim
MedimOPā€¢2y ago
Medim
MedimOPā€¢2y 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ā€¢2y ago
there's no PORT 80?
Medim
MedimOPā€¢2y ago
no lol
Brody
Brodyā€¢2y ago
so where that error coming from rc's demo worked, so what are you changing from his config files?
Medim
MedimOPā€¢2y ago
absolutely nothing
Brody
Brodyā€¢2y ago
I'm tempted to deploy his config files and show you they work, but I'm on mobile
Medim
MedimOPā€¢2y ago
no ports
Medim
MedimOPā€¢2y ago
where is that 80 coming from....
Brody
Brodyā€¢2y ago
can you access that url from the browser? domain*
Ray
Rayā€¢2y ago
where are you getting the 80? Do you have a service variable set for PORT to 8080?
Medim
MedimOPā€¢2y ago
yeah, it goes to the 403 forbidden
Ray
Rayā€¢2y 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
MedimOPā€¢2y 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ā€¢2y ago
locally with nginx+fpm too?
Medim
MedimOPā€¢2y ago
it still errors out as 405 on my local docker and on railway it throws an error 500
Medim
MedimOPā€¢2y ago
yep, same img oh yeah, composer is missing in the img
Ray
Rayā€¢2y ago
ah yeah, looks like you're not building your app dependencies in the image
Medim
MedimOPā€¢2y 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ā€¢2y ago
composer install will install the dependencies into a vendor directory - you'll likely need to copy that into your app's directory
Medim
MedimOPā€¢2y ago
wdym? It justs needs the composer.json to function nvm, composer got its own img so im gonna multi stage it
Brody
Brodyā€¢2y ago
you're definitely over thinking this
Medim
MedimOPā€¢2y ago
yeah
Brody
Brodyā€¢2y ago
you said you modified rc's nginx config file? why? his demo worked fine
Medim
MedimOPā€¢2y ago
I didnt modify it everything was the same, now im modifying his dockerfile cause it wasnt installing the packages
Medim
MedimOPā€¢2y ago
composer packages šŸ‘Œ still 405 tho
Medim
MedimOPā€¢2y ago
same thing... how can it be this weird port...
Medim
MedimOPā€¢2y ago
well, gonna continue tomorrow. I've been 8+ hours on this today really appreciate you guys help
Ray
Rayā€¢2y 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
MedimOPā€¢2y 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
MedimOPā€¢2y ago
logged that apiNfeUrl before using it
Medim
MedimOPā€¢2y ago
I literally have no clue where that 127.0.0.1 come from
Brody
Brodyā€¢2y ago
okay slow tf down get a simple info php script running first, like in mine or rc's examples
Medim
MedimOPā€¢2y 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ā€¢2y ago
Medim
MedimOPā€¢2y 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ā€¢2y 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
MedimOPā€¢2y ago
Hi Angelo! Honestly, you're asking the wrong guy for this. I hate PHP
Brody
Brodyā€¢2y ago
lmfao x400
Medim
MedimOPā€¢2y ago
cryingman
angelo
angeloā€¢2y ago
by hating PHP, that only makes you a better writer
Medim
MedimOPā€¢2y ago
4 days already trying to fix this issue im having
angelo
angeloā€¢2y ago
PHP > lambo doesn't happen without a little bit of pain
Medim
MedimOPā€¢2y 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ā€¢2y ago
i cant stop laughing
Medim
MedimOPā€¢2y ago
brody... i was thinking fast-cgi, uses this combination of file (index.php) + args
Brody
Brodyā€¢2y ago
paraphrasing A: i will pay you for expanding the php docs m: i hate php
Medim
MedimOPā€¢2y ago
what if i change my baseUrl to .../public/index.php since im not hiting it at the root level kekw
Brody
Brodyā€¢2y ago
this is what i did maybe
Medim
MedimOPā€¢2y ago
but u mean at root level? cause u arent doing it in the url .
Brody
Brodyā€¢2y ago
location / {
try_files $uri /index.php?$query_string;
}
location / {
try_files $uri /index.php?$query_string;
}
this is mine
Medim
MedimOPā€¢2y ago
... gonna try that
Brody
Brodyā€¢2y ago
hold on
Medim
MedimOPā€¢2y ago
holding
Brody
Brodyā€¢2y 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
MedimOPā€¢2y 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ā€¢2y ago
the only thing thats in my src folder is index.php all config files are in project root
Medim
MedimOPā€¢2y 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ā€¢2y ago
why not
Brody
Brodyā€¢2y ago
Medim
MedimOPā€¢2y 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ā€¢2y ago
lmfao
Medim
MedimOPā€¢2y 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
MedimOPā€¢2y ago
Medim
MedimOPā€¢2y ago
now i need to know why is it erroring like that cryingman
Brody
Brodyā€¢2y ago
what even is this error dialog
Medim
MedimOPā€¢2y 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ā€¢2y ago
are you able to access index.php from the root yet?
Medim
MedimOPā€¢2y ago
yep
Brody
Brodyā€¢2y ago
yay
Medim
MedimOPā€¢2y 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ā€¢2y 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
MedimOPā€¢2y 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ā€¢2y ago
you need some verbose logs or something lol
Medim
MedimOPā€¢2y ago
i think thats the best slim-php can do really lmao
Brody
Brodyā€¢2y ago
common php L
Brody
Brodyā€¢2y ago
did you provide a token?
Medim
MedimOPā€¢2y ago
...yes
Brody
Brodyā€¢2y ago
in what form query param, header, body?
Medim
MedimOPā€¢2y ago
Brody
Brodyā€¢2y ago
very possible, i know some frameworks wont clean the url
Medim
MedimOPā€¢2y ago
i guess this one doesnt, thats why its giving 405 all over ..oh i got it
Brody
Brodyā€¢2y ago
ideally the framework would return 404 on a malformed path, but slim wants to return 405 ig
Medim
MedimOPā€¢2y 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ā€¢2y ago
its always user error (joke) def need https scheme
Medim
MedimOPā€¢2y ago
well.. redeploying it worked flawlessly
Brody
Brodyā€¢2y ago
I'm so smort (he lied)
Medim
MedimOPā€¢2y 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ā€¢2y ago
bro wouldn't listen to me
Medim
MedimOPā€¢2y ago
lmao
Brody
Brodyā€¢2y ago
tsk tsk tsk
Medim
MedimOPā€¢2y ago
thanks @Brody and @rc you two were of great help and thanks @Finn - uses centos for the emotional support lmfao
Brody
Brodyā€¢2y ago
what so everything works?
Medim
MedimOPā€¢2y 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
MedimOPā€¢2y ago
just wanted to delete this ghost service but seems i'm unable to :kekw:
Brody
Brodyā€¢2y ago
what errors do you get?
Ray
Rayā€¢2y 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
MedimOPā€¢2y ago
"Failed to delete"
Brody
Brodyā€¢2y ago
have you refreshed the page?
Medim
MedimOPā€¢2y ago
Medim
MedimOPā€¢2y ago
many times
Brody
Brodyā€¢2y ago
rip wait it out
Medim
MedimOPā€¢2y ago
{ "message": "Not Authorized", "locations": [ { "line": 2, "column": 3 } ], "path": [ "serviceDelete" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "exception": { "status": 400 } } }
Brody
Brodyā€¢2y ago
funky don't really know what to tell you
Medim
MedimOPā€¢2y ago
its triggering my ocd fix AUGH
Brody
Brodyā€¢2y ago
I do not have such power two other people just reported issues with the API, you're not alone
Medim
MedimOPā€¢2y 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ā€¢2y ago
that's not good
Ray
Rayā€¢2y 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
MedimOPā€¢2y 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": "[email protected]",
"homepage": "http://www.joshlockhart.com/"
},
{
"name": "Pierre Berube",
"email": "[email protected]",
"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": "[email protected]",
"homepage": "http://www.joshlockhart.com/"
},
{
"name": "Pierre Berube",
"email": "[email protected]",
"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ā€¢2y ago
thanks!
Medim
MedimOPā€¢2y ago
np
Ray
Rayā€¢2y ago
railway up works for me using the composer.json with ext-json removed from require
Medim
MedimOPā€¢2y ago
ext-json is an essential extension for our api to run cryingman
Brody
Brodyā€¢2y ago
pin it to a specific version?
Ray
Rayā€¢2y ago
ext-json is included in >php8, there's no need to install it
Medim
MedimOPā€¢2y 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ā€¢2y ago
I don't think nixpacks support that specific php version šŸ˜• your composer requires php^7.2, so nixpacks will build using >8
Medim
MedimOPā€¢2y ago
Yeah, but if it works at php8 thats perfect. We will upgrade to it soon.
Ray
Rayā€¢2y ago
and then you can get rid of the Dockerfile+supervisor/nginx conf šŸ„³
avtomonov
avtomonovā€¢17mo 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ā€¢17mo ago
Ok this is real nice
Brody
Brodyā€¢17mo 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ā€¢17mo ago
sure, thanks, will do now
Want results from more Discord servers?
Add your server