Answer the question
In order to leave comments, you need to log in
How to fix nginx error on server?
Good afternoon.
There was a problem on the production server.
I created a docker image locally and uploaded it to the server.
Naturally, the site did not start.
There is an error in the docker logs on the server
docker logs cont-nginx_1
/docker-entrypoint.sh: Configuration complete; ready for start up
2020/12/28 13:38:57 [emerg] 1#1: open() "/etc/nginx/fastcgi-params" failed (2: No such file or directory) in /etc/nginx/ conf.d/default.conf:26
nginx: [emerg] open() "/etc/nginx/fastcgi-params" failed (2: No such file or directory) in /etc/nginx/conf.d/default.conf :26
docker logs cont-nginx_1
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker- entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/ conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Launching /docker -entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready to start up
nginx:1.19-alpine
server{
listen 80;
server_name _;
index index.php index.html;
root /app/public;
charset utf-8;
add_header X-Frame-Options "SAMEORIGIN";
location ~* \.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|js|css)$ {
access_log off;
expires max;
add_header Pragma public;
add_header Cache-Control "public";
try_files $uri /index.php?$args;
}
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass pohoron-php-fpm:9000;
fastcgi_index index.php;
include fastcgi-params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
docker build --pull --file=site/docker/production/nginx.docker --tag ${REGISTRY_ADDRESS}:nginx-${IMAGE_TAG} site
docker push ${REGISTRY_ADDRESS}:nginx-${IMAGE_TAG}
scp -o StrictHostKeyChecking=no ${PORDUCTION_PORT} docker-compose-production.yml ${PRODUCTION_HOST}:docker-compose.yml
ssh -o StrictHostKeyChecking=no ${PRODUCTION_HOST} -p ${PRODUCTION_PORT} 'docker-compose pull'
ssh -o StrictHostKeyChecking=no ${PRODUCTION_HOST} -p ${PRODUCTION_PORT} 'docker-compose up --build -d'
version: '3'
services:
site-nginx:
image: ${REGISTRY_ADDRESS}:nginx-${IMAGE_TAG}
restart: always
depends_on:
- site-php-fpm
ports:
- "80:80"
site-php-fpm:
image: ${REGISTRY_ADDRESS}:php-fpm-${IMAGE_TAG}
restart: always
environment:
DATABASE_URL: pgsql://app:${DB_PASSWORD}@site-postgres:5432/app
OAUTH_FACEBOOK_SERCRET: ${OAUTH_FACEBOOK_SECRET}
REDIS_URL: tcp://site-redis:6379?password=${REDIS_PASSWORD}
MAILER_URL: null://localhost
depends_on:
- site-postgres
- site-redis
site-redis:
image: ${REGISTRY_ADDRESS}:redis-${IMAGE_TAG}
restart: always
volumes:
- site-redis:/data
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
site-postgres:
site-redis:
FROM nginx:1.19-alpine
COPY ./docker/production/nginx/conf.d /etc/nginx/conf.d
WORKDIR /app
COPY ./public ./public
COPY --from=node-builder /app/public/build ./public/build
Answer the question
In order to leave comments, you need to log in
I can assume that you are forwarding the /etc/nginx/ directory from the host system to the container, and on the server where it does not work, fastcgi-params is absent or is called differently (on Ubuntu 20, for example, it is written through an underscore, and not through hyphen)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question