Modifying ZAC to run on another port

Does anyone know where the setting is?

It runs on 8443… and I want to change it because it conflicts with another service.

I know it will be there somewhere… but have not found it yet.

ahh… after inspecting the repository… looks like its a docker setting. not really sure how to change this… will let you know if I find a way to change it

ok… simple… you edit the docker file :slight_smile:

Actually… its in the server.js file…under Command line Launch Settings

const port = process.env.PORT||1408;
const portTLS = process.env.PORTTLS||8443;

1 Like

Hey @markamind if you’re running in docker and you want a different port on your local machine that’s a very simple adjustment of the -p option.

For example here, if I run this command it will still run on 1408 in the container itself, but on my machine I access ZAC through port 4242. The value to the left is the port that will be exposed on your local machine and the value on the right is the port used in the container.

docker run \
       --name zac \
       -p 4242:1408 \
       -p 8443:8443 \
       -v "${HOME}/docker-volume/myFirstZitiNetwork/ziti-edge-controller-intermediate/keys/ziti-edge-controller-server.key":/usr/src/app/server.key \
       -v "${HOME}/docker-volume/myFirstZitiNetwork/ziti-edge-controller-intermediate/certs/ziti-edge-controller-server.chain.pem":/usr/src/app/server.chain.pem \
       openziti/zac

If you want to change the port in the container itself (or just wherever you’re running ZAC) you can set the environment variable PORT. The code you found in server.js actually looks for the value in the PORT env var but if that’s not set, it defaults to 1408.

For docker that would look like this

docker run \
       --name zac \
       -e PORT=4242 \
       -p 4242:4242 \
       -p 8443:8443 \
       -v "${HOME}/docker-volume/myFirstZitiNetwork/ziti-edge-controller-intermediate/keys/ziti-edge-controller-server.key":/usr/src/app/server.key \
       -v "${HOME}/docker-volume/myFirstZitiNetwork/ziti-edge-controller-intermediate/certs/ziti-edge-controller-server.chain.pem":/usr/src/app/server.chain.pem \
       openziti/zac

Above I am running ZAC on 4242 (-e PORT=4242) so now I can view it from my local machine on 4242 but it’s also running in docker on port 4242.

1 Like

You got it. When you start ZAC - if you set that variable it'll change the port it listens on. Nice sleuthing! :slight_smile:

1 Like