3

Expose nodejs app witch execute on port 3001 on DDEV web container, and access with local port 80 - 443 with SSL for access with https:myproject.ddev.site without add any port.

All without create a new container docker-compose.*.yaml

M3JS
  • 51
  • 4

1 Answers1

2

To expose 3001 port and work with local ports 80-443, you have to create an adapter docker-compose file that extends the web container configuration to expose 3001 port and mapping with your local ports 80-443

docker compose file example

version: '3.6'
services:
  web:
    expose:
      - 3001
    environment:
      - HTTP_EXPOSE=${DDEV_MAILHOG_PORT}:8025,80:3001
      - HTTPS_EXPOSE=${DDEV_MAILHOG_HTTPS_PORT}:8025,443:3001

Then, run ddev ssh, and execute your app nodejs and open https://yourproject.ddev.site

M3JS
  • 51
  • 4
  • Thanks for this! For this to work I think you have to set `router_http_port` and `router_https_port` to something other than 80 and 443 right? Also, you'll want to show people how to start the process, probably with a post-start hook or with a supervisord config as in https://susi.dev/supervisor-ddev – rfay Oct 01 '21 at 13:38