M3JS
M3JS

Reputation: 61

How to expose a Nodejs app with DDEV web container on local port 80 - 443 with SSL

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

Upvotes: 3

Views: 1756

Answers (1)

M3JS
M3JS

Reputation: 61

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

Upvotes: 3

Related Questions