Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currently solved through port mapping bypass. #143

Open
Asmodeo246909 opened this issue Jan 13, 2025 · 0 comments
Open

Currently solved through port mapping bypass. #143

Asmodeo246909 opened this issue Jan 13, 2025 · 0 comments

Comments

@Asmodeo246909
Copy link

Currently solved through port mapping bypass.

root@deepin-1:~/nginx-cluster# docker-compose ps -a 
NAME                      IMAGE                 COMMAND                  SERVICE   CREATED              STATUS                        PORTS
nginx-cluster-haproxy-1   haproxy:alpine3.19    "docker-entrypoint.s…"   haproxy   About a minute ago   Up About a minute (healthy)   0.0.0.0:443->8443/tcp
nginx-cluster-nginx1-1    nginx:1.25.3-alpine   "/docker-entrypoint.…"   nginx1    About a minute ago   Up About a minute (healthy)   80/tcp
nginx-cluster-nginx2-1    nginx:1.25.3-alpine   "/docker-entrypoint.…"   nginx2    About a minute ago   Up About a minute (healthy)   80/tcp
root@deepin-1:~/nginx-cluster# 
root@deepin-1:~/nginx-cluster# cat docker-compose.yaml 
version: '3'
services:
  haproxy:
    image: haproxy:alpine3.19
    environment:
      TZ: ${TIMEZONE}
    volumes:
      - ./conf/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
      - ./certs:/etc/ssl/private:ro
      - /data/logs/haproxy:/var/log/haproxy:rw 
    ports:
      - "${PORT_SERVER}:8443"
    networks:
      - webnet
    privileged: true
    restart: unless-stopped
    healthcheck: 
      test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
      interval: 30s
      timeout: 10s
      retries: 3
    logging: 
      driver: json-file
      options:
        max-size: "500m"
        max-file: "3"

  nginx1:
    image: nginx:${VERSION}
    environment:
      TZ: ${TIMEZONE}
    volumes:
      - ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./certs:/etc/ssl/private:ro
      - ./html:/usr/share/nginx/html
      - /data/logs/nginx1:/var/log/nginx:rw 
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "nginx -t && ps aux | grep '[n]ginx: master process' || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - webnet
    depends_on:
      - haproxy
    logging: 
      driver: json-file
      options:
        max-size: "300m"
        max-file: "3"

  nginx2:
    image: nginx:${VERSION}
    environment:
      TZ: ${TIMEZONE}
    volumes:
      - ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./certs:/etc/ssl/private:ro
      - ./html:/usr/share/nginx/html
      - /data/logs/nginx2:/var/log/nginx:rw 
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "nginx -t && ps aux | grep '[n]ginx: master process' || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - webnet
    depends_on:
      - haproxy
    logging: 
      driver: json-file
      options:
        max-size: "300m"
        max-file: "3"

networks:
  webnet:
root@deepin-1:~/nginx-cluster# 
root@deepin-1:~/nginx-cluster# 
root@deepin-1:~/nginx-cluster# 
root@deepin-1:~/nginx-cluster# cat conf/haproxy.cfg 
global
    log stdout format raw local0
    # Tune SSL options for better performance
    tune.ssl.default-dh-param 2048

defaults
    log     global
    option  httplog
    option  dontlognull
    timeout connect 5000ms
    timeout client  50000ms
    timeout server  50000ms

# Frontend configuration
frontend https_in
    mode http
    bind *:8443 ssl crt /etc/ssl/private/localserver.com.pem
    redirect scheme https code 301 if !{ ssl_fc }
    default_backend   http_servers
    

# Backend configuration
backend http_servers
      mode http
      balance roundrobin
      option httpchk HEAD /
      http-response set-header X-Frame-Options SAMEORIGIN
      http-response set-header X-XSS-Protection 1;mode=block
      http-response set-header X-Content-Type-Options nosniff
      #default-server check maxconn 5000
      retries 5
      timeout connect 5s
      timeout server 30s
      timeout check 10s
      server nginx1 nginx1:443 ssl verify none check inter 10s fall 3 rise 2
      server nginx2 nginx2:443 ssl verify none check inter 10s fall 3 rise 2
root@deepin-1:~/nginx-cluster# cat .env
VERSION=1.25.3-alpine

TIMEZONE=Asia/Shanghai

PORT_SERVER=443

Publicado originalmente por @ghost en docker-library/haproxy#160 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant