Hello, i have big trouble to set up my nginx container to be allow to connect to my localhost:443, on localhost:80 everything is perfect but with 443 it's not.
i'm using docker compose here's the file :
services:
nginx:
build: ./requirements/nginx/.
container_name: nginx
ports:
- "443:443"
- "80:80"
restart: always
wordpress:
build: ./requirements/wordpress/.
container_name: wordpress
ports:
- "9000:9000"
restart: always
Here's my dockerfile :
FROM debian:bullseye-slim
RUN apt update -y && apt upgrade -y && apt install -y nginx
RUN apt install -y openssl && apt install -y vim
RUN apt install -y systemctl
COPY default /etc/nginx-available/.
COPY script.sh .
RUN bash script.sh
CMD ["bash", "script.sh"]
CMD ["nginx", "-g", "daemon off;"]
here's the server block i had to my /etc/nginx/sites-available/default nginx container :
echo "server {
listen 443 ssl;
listen [::]:443 ssl;
server_name default_server;
ssl_certificate /etc/ssl/certs/selfsigned.crt;
ssl_certificate_key /etc/ssl/private/selfsigned.key;
ssl_protocols TLSv1.3;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files / =404;
}
}
I've set my openssl certification. With docker ps i can see my nginx is using 0.0.0.0:443->443/tcp
When i writing :
lsof -i :443
lsof -i 80
I have this
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 39 root 8u IPv4 222201 0t0 TCP *:443 (LISTEN)
nginx 39 root 9u IPv6 222202 0t0 TCP *:443 (LISTEN)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 39 root 6u IPv4 222199 0t0 TCP *:80 (LISTEN)
nginx 39 root 7u IPv6 222200 0t0 TCP *:80 (LISTEN)
but when i try to localhost:443 on my google url i have a 400 bad request, i have any idea about what can be the issu
i'm using docker compose here's the file :
services:
nginx:
build: ./requirements/nginx/.
container_name: nginx
ports:
- "443:443"
- "80:80"
restart: always
wordpress:
build: ./requirements/wordpress/.
container_name: wordpress
ports:
- "9000:9000"
restart: always
Here's my dockerfile :
FROM debian:bullseye-slim
RUN apt update -y && apt upgrade -y && apt install -y nginx
RUN apt install -y openssl && apt install -y vim
RUN apt install -y systemctl
COPY default /etc/nginx-available/.
COPY script.sh .
RUN bash script.sh
CMD ["bash", "script.sh"]
CMD ["nginx", "-g", "daemon off;"]
here's the server block i had to my /etc/nginx/sites-available/default nginx container :
echo "server {
listen 443 ssl;
listen [::]:443 ssl;
server_name default_server;
ssl_certificate /etc/ssl/certs/selfsigned.crt;
ssl_certificate_key /etc/ssl/private/selfsigned.key;
ssl_protocols TLSv1.3;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files / =404;
}
}
I've set my openssl certification. With docker ps i can see my nginx is using 0.0.0.0:443->443/tcp
When i writing :
lsof -i :443
lsof -i 80
I have this
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 39 root 8u IPv4 222201 0t0 TCP *:443 (LISTEN)
nginx 39 root 9u IPv6 222202 0t0 TCP *:443 (LISTEN)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 39 root 6u IPv4 222199 0t0 TCP *:80 (LISTEN)
nginx 39 root 7u IPv6 222200 0t0 TCP *:80 (LISTEN)
but when i try to localhost:443 on my google url i have a 400 bad request, i have any idea about what can be the issu