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

Multi-Environment Setup leads to Error 418 #7

Open
FlxHbr opened this issue Apr 21, 2023 · 1 comment
Open

Multi-Environment Setup leads to Error 418 #7

FlxHbr opened this issue Apr 21, 2023 · 1 comment

Comments

@FlxHbr
Copy link

FlxHbr commented Apr 21, 2023

Hi to everybody! First of all, thanks for dockware.

However, i am struggling to setup a multi channel shop. I am getting "Error 418 - I'm a teapot", whatever i do. I am developing on Mac (M1, Venutra 13.2.1, so nginx is in opt/homebrew/etc/ngnix).

I start the containers with docker compose, everything runs fine. "make init" runs as well, but after opening "http://shop1.shopware.com/" the Error 418 occurs. etc/hosts is changed and the urls are added. I added the urls to my backend channels as well.

docker-compose-yml:

version: "3"

services:

  proxy:
    container_name: proxy
    image: dockware/proxy:latest
    ports:
      - "80:80"
      - "3306:3306"
      - "22:22"
      - "443:443"
      - "3000:3000"
      - "8888:8888"
      - "9999:9999"
      - "9998:9998"
    depends_on:
      - shop1
      - shop2
    volumes:
      - "db_volume:/var/lib/mysql"
      - "./src:/var/www/html/"
      # ...excluding shopware default directories
      - "/var/www/html/.git/"
      - "/var/www/html/public/build"
      - "/var/www/html/var/cache"
      - "/var/www/html/vendor"
      # ...additional project specific excludes...
      - "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/administration/node_modules/"
      - "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/storefront/node_modules/"
      - "/var/www/html/custom/plugins/MyPlugin/tests/Cypress/"
      - "./proxy/shop-1.conf:/opt/homebrew/etc/nginx/conf.d/shop-1.conf"
      - "./proxy/shop-2.conf:/opt/homebrew/etc/nginx/conf.d/shop-2.conf"
    networks:
      - web
    environment:
      # default = 0, recommended to be OFF for frontend devs
      - XDEBUG_ENABLED=0
  # -----------------------------------------------------------------------
  shop1:
    image: dockware/dev:latest
    container_name: shop1
    ports:
      - "2001:22"
      - "3001:3306"
  shop2:
    image: dockware/dev:latest
    container_name: shop2
    ports:
      - "2002:22"
      - "3002:3306"
volumes:
  db_volume:
    driver: local

networks:
  web:
    external: false

makefile:

.PHONY: help
.DEFAULT_GOAL := help

help:
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

# ---------------------------------------------------------------------------------------------

init: ## Installs and initializes all environments
	docker exec -i shop1 mysql -uroot -proot shopware < ./database/add-https.sql
	docker exec -it shop1 bash -c 'php bin/console sales-channel:update:domain shop1.shopware.com'
	docker exec -it shop1 bash -c 'php bin/console cache:clear'
	# -----------------------------------------------------------------------------------------------------------
	docker exec -i shop2 mysql -uroot -proot shopware < ./database/add-https.sql
	docker exec -it shop2 bash -c 'php bin/console sales-channel:update:domain shop2.shopware.com'
	docker exec -it shop2 bash -c 'php bin/console cache:clear'
	# -----------------------------------------------------------------------------------------------------------
	open https://shop1.shopware.com
	open https://shop2.shopware.com

download: ## Downloads files from the container to your host
	mkdir -p ../../src/shop1
	mkdir -p ../../src/shop2
	docker cp shop1:/var/www/html/. ../../src/shop1
	docker cp shop2:/var/www/html/. ../../src/shop2

watch-storefront: ## Starts the Storefront Watcher, [make storefront-admin shop=shop1]
	bash -c "trap 'make stop-watch-storefront' EXIT; docker exec -it $(shop) bash -c 'cd /var/www && APP_URL=http://0.0.0.0 make watch-storefront'"

watch-admin: ## Starts the Admin Watcher, [make watch-admin shop=shop1]
	docker exec -it $(shop) bash -c 'cd /var/www && make watch-admin'

shop-1.conf (shop-2.conf is identical, except that "1" is changed of course):

server {
    listen        80;
    server_name   shop1.shopware.com;
    return 301    https://$host$uri$is_args$args;
}

server {
    listen        443 ssl;
    server_name   shop1.shopware.com;

    ssl_certificate /etc/nginx/ssl/selfsigned.crt;
    ssl_certificate_key /etc/nginx/ssl/selfsigned.key;

    location / {
        proxy_pass https://shop1;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    }
}

server {
    listen                    8888 ssl;
    server_name               shop1.shopware.com;

    ssl_certificate /etc/nginx/ssl/selfsigned.crt;
    ssl_certificate_key /etc/nginx/ssl/selfsigned.key;

    location /admin {
        proxy_pass            http://shop1:8888;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
    location /static {
        proxy_pass            http://shop1:8888;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
    location /api {
        proxy_pass            http://shop1;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
    location / {
        proxy_pass            http://shop1:8888;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
}

server {
    listen                    9998;
    server_name               shop1.shopware.com;

    location / {
        proxy_set_header      Host    localhost;
        proxy_pass            http://shop1:9998;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
}

Maybe it is just me misunderstanding or misconfiguring?
Thanks a lot!

@MinhVu2711
Copy link

try to remove two ports 3306 and 22 in your proxy service @FlxHbr

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