# How to deploy Next.js 9.5 with Dockerfile on Traefik

**URL:** <https://community.traefik.io/t/how-to-deploy-next-js-9-5-with-dockerfile-on-traefik/7429>\
**Category:** Traefik v2\
**Tags:** docker, middleware\
**Created:** [August 26, 2020, 9:09pm UTC](https://community.traefik.io/t/how-to-deploy-next-js-9-5-with-dockerfile-on-traefik/7429 "2020-08-26T21:09:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatihyildizhan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/fatihyildizhan/32/2489_2.png) [@fatihyildizhan](https://community.traefik.io/u/fatihyildizhan)\
**Post date:** [August 26, 2020, 9:09pm UTC](https://community.traefik.io/t/how-to-deploy-next-js-9-5-with-dockerfile-on-traefik/7429/1 "2020-08-26T21:09:05Z")

</div>

Hi,

I am getting bad gateway or 404 page not found error. How can I serve Next.js as a Docker image on Traefik v2.2.8?

Dockerfile

```auto
FROM node:12.18.3-alpine3.12

COPY . /app
WORKDIR /app

RUN npm install

RUN npm run build

EXPOSE 3000

CMD ["npm", "run", "start"]

```

.dockerignore

```auto
.next/
node_modules/
.git
.gitignore
Dockerfile

```

Server port is 80 on Traefik's docker-compose.yml  
`- "traefik.http.services.simple-nextjs.loadbalancer.server.port=80"`

---

<div class="post-metadata">

**Author:** ![fatihyildizhan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/fatihyildizhan/32/2489_2.png) [@fatihyildizhan](https://community.traefik.io/u/fatihyildizhan)\
**Post date:** [August 28, 2020, 4:54am UTC](https://community.traefik.io/t/how-to-deploy-next-js-9-5-with-dockerfile-on-traefik/7429/2 "2020-08-28T04:54:19Z")

</div>

This solution worked for me.

Dockerfile

```auto
FROM node:12

ENV PORT 3000

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Installing dependencies
COPY package*.json /usr/src/app/
RUN npm install

# Copying source files
COPY . /usr/src/app

# Building app
RUN npm run build
EXPOSE 3000

# Running the app
CMD "npm" "run" "start"

```

Change port to 3000  
`- "traefik.http.services.simple-nextjs.loadbalancer.server.port=3000"`
