The error reported is:
app-client_1 | 2022/01/18 21:21:55 [emerg] 22#22: bind() to 0.0.0.0:443 failed (98: Address in use)
app-client_1 | nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address in use)
app-client_1 | 2022/01/18 21:21:55 [emerg] 22#22: bind() to 0.0.0.0:80 failed (98: Address in use)
app-client_1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
The ssl works, but my docker container is restarting in loop.
In my nginx container, when I set in my entrypoint.sh to run the certbot command, still doing the restart, mas but if I remove and run the same command after the container start, it works.
nginx.conf:
user nginx;
# auto detects a good number of processes to run
worker_processes auto;
#Provides the configuration file context in which the directives that affect connection processing are specified.
events {
# Sets the maximum number of simultaneous connections that can be opened by a worker process.
worker_connections 8000;
# Tells the worker to accept multiple connections at a time
multi_accept on;
}
http {
server {
listen 80;
server_name teste-4.codepec.com;
location / {
root /var/www;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /api/ {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# redirect api calls to the api container, running on the same docker-compose
proxy_pass http://app-server:8380/;
}
}
}
#### Stage 1: Build the react application
FROM node:16.13.2-alpine as build
# Configure the main working directory inside the docker image.
# This is the base directory used in any further RUN, COPY, and ENTRYPOINT
# commands.
WORKDIR /app
# Copy the package.json as well as the yarn-lock.json and install
# the dependencies. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY package.json yarn.lock ./
RUN yarn install --network-timeout 1000000000
# Copy the main application
COPY . ./
ARG PROFILE
# Build the application
RUN yarn $PROFILE
#### Stage 2: Serve the React application from Nginx
FROM nginx:1.21.5-alpine
# Install certbot
RUN apk add --no-cache bash curl && \
apk add --no-cache certbot certbot-nginx
# Copy the react build from Stage 1
COPY --from=build /app/build /var/www
# Copy renew cron script
COPY nginx/renew /etc/periodic/daily/renew
RUN chmod +x /etc/periodic/daily/renew
RUN mkdir /etc/letsencrypt
# Copy nginx script to set envsubst
COPY nginx/scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Copy our custom nginx template config
COPY nginx/templates /etc/nginx/templates/
VOLUME /etc/letsencrypt
ENTRYPOINT ["/entrypoint.sh"]
that sounds like init script ran too early to run certbot, and containers internal script didn't expect nginx to be already started. put certbot command after nginx -g
-------- 원본 이메일 --------
발신: Gildo Neto via Let's Encrypt Community Support letsencrypt@discoursemail.com
날짜: 22/1/19 07:30 (GMT+09:00)
받은 사람: tjtncks@gmail.com
제목: [Let's Encrypt Community Support] [Help] Certbot --nginx generate and install but my container is restarting in loop with nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address in use) and nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
#### Stage 1: Build the react application
FROM node:16.13.2-alpine as build
# Configure the main working directory inside the docker image.
# This is the base directory used in any further RUN, COPY, and ENTRYPOINT
# commands.
WORKDIR /app
# Copy the package.json as well as the yarn-lock.json and install
# the dependencies. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY package.json yarn.lock ./
RUN yarn install --network-timeout 1000000000
# Copy the main application
COPY . ./
ARG PROFILE
# Build the application
RUN yarn $PROFILE
#### Stage 2: Serve the React application from Nginx
FROM nginx:1.21.5-alpine
# Install certbot
RUN apk add --no-cache bash curl && \
apk add --no-cache certbot certbot-nginx
# Copy the react build from Stage 1
COPY --from=build /app/build /var/www
# Copy renew cron script
COPY nginx/renew /etc/periodic/daily/renew
RUN chmod +x /etc/periodic/daily/renew
RUN mkdir /etc/letsencrypt
# Copy nginx script to set envsubst
COPY nginx/scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Copy our custom nginx template config
COPY nginx/templates /etc/nginx/templates/
VOLUME /etc/letsencrypt
ENTRYPOINT ["/entrypoint.sh"]
not a delay but reorder. I think this may work. but it shouldn't run in container anyway: probably meet duplicate certificate rate limit fast. (look at that it needed to register new account each time)