eclipse / hawkbit

Eclipse hawkBit™
https://projects.eclipse.org/projects/iot.hawkbit
Eclipse Public License 2.0
453 stars 187 forks source link

Can't change Hawkbit Artifact Port on HTTP when running through Docker #831

Closed ghost closed 4 years ago

ghost commented 5 years ago

We're currently running version 0.3.0 of Hawkbit through a Docker container, hosted in AWS Elastic Beanstalk. Previously we used the default port (8080) for HTTP requests, including when downloading artifact files.

However, for various reasons (mostly that some of our clients may block non-default ports) we've decided we want to change so that the default port used is 80.

We did by changing the xposed Docker port and by setting server.port when initializing Hawkbit through a shell script: java -jar hawkbit-update-server.jar [...] --server.port=80 [...]

While did made the Hawkbit web portal run on 80, it didn't change the port from 8080 when fetching artifact URL's:

{
  "id": "43",
  "deployment": {
    "download": "forced",
    "update": "forced",
    "chunks": [{
        "part": "os",
        "version": "<OUR-VERSION>",
        "name": "<OUR-NAME>",
        "artifacts": [{
            // ...
            "_links": {
              "download-http": {
                "href": "http://<OUR-HOST>:8080/DEFAULT/controller/v1/<OUR-ID>/softwaremodules/63/artifacts/<OUR-ARTIFACT>.swu"
              },
              "md5sum-http": {
                "href": "http://<OUR-HOST>:8080/DEFAULT/controller/v1/<OUR-ID>/softwaremodules/63/artifacts/<OUR-ARTIFACT>.swu.MD5SUM"
              }
            }
          }
        ]
      }
    ]
  }
}

After some further Googling I've discovered an old issue, where it appears that to change the port used when fetching artifacts you need to specify a different property:

To fix this, we've tried adding the hawkbit.artifact.url.http.port property when initializing Hawkbit: java -jar hawkbit-update-server.jar [...] --server.port=80 --hawkbit.artifact.url.http.port=80 [...] However, this didn't seem to fix our issue.

I've also tested forking the GitHub repository, and manually updating application.properties so that it has the above property, but that also didn't fix our issue:

Is there anything else that needs to be set if we want to use port 80 for our artifact links?

Thanks in advance!

schabdo commented 5 years ago

Unfortunately the properties from https://github.com/eclipse/hawkbit/issues/173 won't work in a newer version of HawkBit. We introduced the ability to offer more protocols to the client for downloading files (same file e.g. with HTTP and/or HTTPS whatever you support). In order to only change the port your properties should look like this:

hawkbit.artifact.url.protocols.download-http.port=80
hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostnameRequest}:{port}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}

The second property seems to be required in your case as well. Don't know how you access the server because default port is the port of the incoming request. Anyway with the given properties above it should work.

The basic idea is that you could configure placeholder and construct the url dynamically e.g:

hawkbit.artifact.url.protocols.download-http.rel=https
hawkbit.artifact.url.protocols.download-http.protocol=https
hawkbit.artifact.url.protocols.download-http.port=9999
hawkbit.artifact.url.protocols.download-http.hostname=myMydownload.com
hawkbit.artifact.url.protocols.download-http.ip=127.0.0.1
hawkbit.artifact.url.protocols.download-http.supports=DDI
hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostname}:{port}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}

Hope this helps to solve your issue

ghost commented 5 years ago

Adding the two properties you mentioned worked perfectly, thanks!

I couldn't find any information about the hawkbit.artifact.url.protocols.download-http on Hawkbit's documentation homepage (https://www.eclipse.org/hawkbit/). Would it be possible to add info about them there, so that it's more apparent how to change how the artifact URLs are generated?

schabdo commented 5 years ago

Sure! May I ask you to create a new GitHub issue for this? Furthermore (if you like) I encourage you to raise a pull request to extend the documentation. I think the "Guides" section would be a good fit. Source is located here. For sure you'll have our support in case of questions

schabdo commented 4 years ago

I close this issue for now. Feel free to reopen it in case your issue is not solved

Yusufss4 commented 1 year ago

I'm new to development in Java and I could not find the right place to put these proporties? Where should I add them? In the hawkbit\hawkbit-autoconfigure\src\main\resources\hawkbit-artifactdl-defaults.properties ?

hawkbit.artifact.url.protocols.download-http.port=80
hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostnameRequest}:{port}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}

Any help is greatly appreciated. Thanks.

strailov commented 1 year ago

Hey @Yusufss4 ! Probably the best place for them is application.properties file located in hawkbit/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties.