intel / Edge-Software-Provisioner

BSD 3-Clause "New" or "Revised" License
42 stars 31 forks source link

How to change the port 80 and port 443 used by ESP to some other port ? #23

Open bhardwaj-nakul opened 2 years ago

bhardwaj-nakul commented 2 years ago

ESP uses port 80[HTTP] and port 443[HTTPS] to host nginx server. During provisioning, http and https calls route to their default port numbers. Is there a way that we can specify in ESP to change these default ports to user defined port numbers ?

dvintel commented 2 years ago

It is currently not supported, but you could manually modify the docker-compose file to change the ports. https://github.com/intel/Edge-Software-Provisioner/blob/ed15845c3273fa66210dc0cf811801d45e47b8c8/docker-compose.yml#L62

You would also have to change the way that the kernel parameter: HOSTIP is set https://github.com/intel/Edge-Software-Provisioner/blob/53a03b2c79910c3e7c052a3ee82be8e5f8ce4f70/scripts/profileutils.sh#L663

So that the client machines can get back to the Edge Software Provisioner during PXE boot

bhardwaj-nakul commented 2 years ago

Okay, we can change the ports in docker-compose file. That will get the nginx server to host on user defined port. https://github.com/intel/Edge-Software-Provisioner/blob/ed15845c3273fa66210dc0cf811801d45e47b8c8/docker-compose.yml#L63 Let's say I have to change the http port from 80 to 8888, then I can modify this line as 8888:80

Now, to set the HOSTIP with modified port number, will we need to provide the HOSTIP:8888 through config.yml ? https://github.com/intel/Edge-Software-Provisioner/blob/ed15845c3273fa66210dc0cf811801d45e47b8c8/conf/config.yml#L16 If we do this then won't there be a conflict where port numbers are hardcoded or where HTTPS calls are being made, as highlighted in following instances ?

https://github.com/intel/Edge-Software-Provisioner/blob/53a03b2c79910c3e7c052a3ee82be8e5f8ce4f70/dockerfiles/uos/bash/init#L70 https://github.com/intel/Edge-Software-Provisioner/blob/53a03b2c79910c3e7c052a3ee82be8e5f8ce4f70/dockerfiles/uos/bash/init#L76 https://github.com/intel/Edge-Software-Provisioner/blob/9eda8c3405439c77cd5dd08d1f6969b104c6ef71/scripts/espctl.sh#L164

How do you suggest we safely set the HOSTIP ?

dvintel commented 2 years ago

Correct, you can change the port in the docker compose file which will get nginx to serve on the desired port.

Also correct, you have to make sure you check all the places where host IP is used and make sure that it is not having a port appended. It IS NOT enough to just specify the port in the config file. Off the top of my head, there should be something for the git tea instance, but I'm sure there are other places.

Sorry there isn't an easy turn-key solution, this portion was not designed to be configurable. However, we could add it to the back log if there is enough demand for it. If you are successful, it would be great to get a PR!

brod-intel commented 2 years ago

What else are you running on the same system?

There is a possible work around, but it depends what you are running on the same system hosted with ESP. You can use HAProxy container to do path-based redirection or URI redirection.

You can setup an HAProxy policy like this:

When someone access http://{ESP_IP_ADDRESS}/my_cool_webservice/ it proxies to http://127.0.0.1:8081/ (which is running your software) Default behavior, when the ESP Profiles access http://{ESP_IP_ADDRESS}/ it proxies to http://127.0.0.1:8080/ (which is running ESP Nginx)