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

I try to edit ngix file and then i m using docker-compose-prod.yml but not working #102

Open
sunilit42 opened this issue Apr 17, 2023 · 9 comments

Comments

@sunilit42
Copy link

sunilit42 commented Apr 17, 2023

Hello,

I try to set custom domain into ngix file so i need to use docker-compose-prod.yml
but when i use docker-compose-prod.yml, it is not working

Version in "./docker-compose-prod.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

My docker version : Docker version 20.10.18, build b40c2f6

@vtsykun
Copy link
Owner

vtsykun commented Apr 17, 2023

Hi
More simple way to setup domain is use nginx proxy in the root host

you can use simple docker-compose.yml

version: '3.6'

services:
    packeton:
        image: packeton/packeton:latest
        container_name: packeton
        hostname: packeton
        ports:
            - '127.0.0.1:8089:80'
        environment:
            TRUSTED_PROXIES: 172.16.0.0/12
            DATABASE_URL: "mysql://app:!ChangeMe!@ec2-host.example.com:3306/app?serverVersion=8&charset=utf8mb4"
        volumes:
            - .docker:/data

Then you need to nginx / apache to the root host and proxy request to local 8089 port - where 8089

        ports:
            - '127.0.0.1:8089:80'

Example nginx proxy config is

server {
    listen 443 ssl http2;
    server_name satis.example.org;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/satis.example.org/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/satis.example.org/privkey.pem; # managed by Certbot
    ssl_session_cache    shared:SSL:10m;
    ssl_session_timeout  10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv2';

    add_header Strict-Transport-Security max-age=15768000;
 
    location / {
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_pass          http://localhost:8089;
        proxy_read_timeout  90;
    }

}

server {
    if ($host = satis.example.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    return 301 https://$host$request_uri;
    server_name satis.example.org;
}

The second why is use jwilder/nginx-proxy docker image to step up nginx proxy via docker. Also you may to use jrcs/letsencrypt-nginx-proxy-companion docker to get letsencrypt

version: '3.6'

services:
    packeton:
        image: packeton/packeton:latest
        container_name: packeton
        hostname: packeton
        ports:
            - '127.0.0.1:8089:80'
        environment:
            VIRTUAL_HOST: satis.example.com
            LETSENCRYPT_HOST: satis.example.com
            LETSENCRYPT_EMAIL: sysadmin@example.com
    
            TRUSTED_PROXIES: 172.16.0.0/12
            DATABASE_URL: "mysql://app:!ChangeMe!@ec2-host.example.com:3306/app?serverVersion=8&charset=utf8mb4"
        volumes:
            - .docker:/data

networks:
  default:
    external:
      name: webproxy

Where VIRTUAL_HOST, LETSENCRYPT_HOST, LETSENCRYPT_EMAIL used for jrcs/letsencrypt-nginx-proxy-companion jwilder/nginx-proxy
See docs https://hub.docker.com/r/jwilder/nginx-proxy
https://github.com/jwilder/docker-letsencrypt-nginx-proxy-companion

@sunilit42
Copy link
Author

I think we need to map - ./src/nginx.conf.sample:/var/www/html/nginx.conf:cached something right?

@sunilit42
Copy link
Author

sunilit42 commented Apr 21, 2023

Hello,

I try to below way but not working
`version: '2.2'

x-volumes: &default-volume
volumes:
- app-data:/data
- app-var:/var/www/packagist/var

x-restart-policy: &restart_policy
restart: unless-stopped

x-environment: &default-environment
REDIS_URL: redis://redis
DATABASE_URL: "postgresql://packeton:pack123@postgres:5432/packeton?serverVersion=14&charset=utf8"
SKIP_INIT: 1

services:
redis:
image: redis:7-alpine
hostname: redis
<<: *restart_policy
volumes:
- redis-data:/data

postgres:
    image: postgres:14-alpine
    hostname: postgres
    <<: *restart_policy
    volumes:
        - postgres-data:/var/lib/postgresql/data
    environment:
        POSTGRES_USER: packeton
        POSTGRES_PASSWORD: pack123
        POSTGRES_DB: packeton

php-fpm:
    image: packeton/packeton:latest
    hostname: php-fpm
    command: ['php-fpm', '-F']
    <<: *restart_policy
    <<: *default-volume
    environment:
        <<: *default-environment
        SKIP_INIT: 0
        WAIT_FOR_HOST: 'postgres:5432'
    depends_on:
        - "postgres"
        - "redis"

nginx:
    image: packeton/packeton:latest
    hostname: nginx
    volumes:
        -   ./docker/nginx:/var/www/packagist/docker/nginx
    ports:
        - '127.0.0.1:8088:80'
    <<: *restart_policy
    <<: *default-volume
    command: >
        bash -c 'sed s/_PHP_FPM_HOST_/php-fpm:9000/g < docker/nginx/nginx-tpl.conf > /etc/nginx/nginx.conf && nginx'
    environment:
        <<: *default-environment
        WAIT_FOR_HOST: 'php-fpm:9000'
    depends_on:
        - "php-fpm"

worker:
    image: packeton/packeton:latest
    hostname: packeton-worker
    command: ['bin/console', 'packagist:run-workers', '-v']
    user: www-data
    <<: *restart_policy
    <<: *default-volume
    environment:
        <<: *default-environment
        WAIT_FOR_HOST: 'php-fpm:9000'
    depends_on:
        - "php-fpm"

cron:
    image: packeton/packeton:latest
    hostname: packeton-cron
    command: ['bin/console', 'okvpn:cron', '--demand', '--time-limit=3600']
    user: www-data
    <<: *restart_policy
    <<: *default-volume
    environment:
        <<: *default-environment
        WAIT_FOR_HOST: 'php-fpm:9000'
    depends_on:
        - "php-fpm"

volumes:
redis-data:
postgres-data:
app-data:
app-var:
`

And nginx-tpl.conf file

`daemon off;
user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

server_tokens off;
default_type application/octet-stream;
include /etc/nginx/mime.types;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log off;

gzip on;
gzip_disable "msie6";
client_max_body_size 10M;
server {
    server_name repo.custom.com;
    listen 80 default_server;
    root /var/www/packagist/public;

    location / {
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /index.php/$1 last;
    }

    fastcgi_buffers 128 128k;
    fastcgi_buffer_size 256k;
    location ~ ^/index\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        send_timeout 600;
        fastcgi_read_timeout 600;
        fastcgi_pass _PHP_FPM_HOST_;
    }

    location ~ \.php$ {
        return 404;
    }
    access_log off;
}

}
`

@vtsykun
Copy link
Owner

vtsykun commented Apr 21, 2023

Hi
Must be version: '3.9'

@sunilit42
Copy link
Author

sunilit42 commented Apr 21, 2023

ERROR: Version in "./docker-compose-prod.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

In your composer file I added
volumes:
- ./docker/nginx:/var/www/packagist/docker/nginx
for copy nginx file

@vtsykun
Copy link
Owner

vtsykun commented Apr 21, 2023

Hi, please use the simple single docker container or update docker-compose

https://github.com/vtsykun/packeton/blob/master/docker-compose.yml

@vtsykun
Copy link
Owner

vtsykun commented Apr 21, 2023

Also nginx configuration was loaded from /etc/nginx
The volumes will be ignore

  • ./docker/nginx:/var/www/packagist/docker/nginx

@sunilit42
Copy link
Author

@vtsykun how i can set the custom domain without modifying ngix file? that's why I m doing volume mapping using that I can setup domain name

@vtsykun
Copy link
Owner

vtsykun commented Apr 21, 2023

Hi, can you install nginx/apache on the root host? more simple to reverse proxy on host machine to setup ssl and custom domain, no need to change docker nginx configuration to setup custom domain.

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

2 participants