Timeline for JSS Deployed to Docker Container: Links to media files missing port number
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 14, 2020 at 13:26 | comment | added | KingTwinkie |
To help people using this answer, we setup static IPs on our containers so that we don't have to update our hosts file whenever the container restarts.
|
|
Sep 9, 2020 at 13:44 | comment | added | KingTwinkie | Sorry Alessandro, I can accept the answer but not upvote since my reputation is too low (I'm a new StackExchange member) :( | |
Sep 9, 2020 at 13:40 | vote | accept | KingTwinkie | ||
Sep 9, 2020 at 13:38 | comment | added | KingTwinkie |
Although Alessandro's solution works, I'm still curious if there is a way to configure Sitecore to render image/media URLs with a port number. An ideal solution is that the URLs would be rendered using the sitecore.layoutServiceHost setting in the scjssconfig.json (or another similar setting) since you can specify port numbers in that setting and Sitecore Integrated mode renders a page that makes requests using that hostname-port combination. It would also avoid having to deal with the problem of the IP changing whenever a container restarts and reduce setup steps for new devs.
|
|
Sep 9, 2020 at 13:37 | comment | added | Alessandro Faniuolo | I am glad that it worked! Please upvote and accept the answer. Thanks! | |
Sep 9, 2020 at 13:32 | comment | added | KingTwinkie |
Thanks Alessandro! I got it working using your hosts suggestion. The part I didn't understand earlier is that the containers had their own IP, I thought it was only accessible through the port forwarding from localhost. Also, you have to let your host file change sit there for a few minutes...probably some routing tables need to get updated. Yea, the IP address returned by docker inspect was slightly different in our config as it's at NetworkSettings.Networks.<name of network adapter for services>.IPAddress .
|
|
Sep 8, 2020 at 15:29 | comment | added | Alessandro Faniuolo | Once you have the correct hosts file record, you will be able to browse your instance without using a port. The docker engine takes care of forwarding your incoming request to the open port. | |
Sep 8, 2020 at 15:26 | comment | added | Alessandro Faniuolo |
@KingTwinkie The IP address of the running container should not be your localhost IP (127.0.0.1). When you run docker inspect <container_name> , the IP address of your container will be under NetworkSettings.Networks.nat.IPAddress (if you are using the nat network).
|
|
Sep 8, 2020 at 15:00 | comment | added | KingTwinkie | Similarly, modifying the alias in the docker-compose doesn't allow for aliasing the IP with the port number. I gave that a try too just in case, and it led to the same web browser error. | |
Sep 8, 2020 at 14:50 | comment | added | KingTwinkie |
Thanks Alessandro! However, please correct me if I'm wrong, but the hosts file only allows for DNS hostname resolution so it won't be able to redirect a hostname in a URL to a specific IP and port. For example, I already have this in my hosts file (and I tried it with the IP returned by docker inspect as you suggested) 127.0.0.1 jss.sc9.local but the following is illegal (the browser just returns an error since it can't find a page) 127.0.0.1:44001 jss.sc9.local
|
|
Sep 6, 2020 at 3:07 | history | answered | Alessandro Faniuolo | CC BY-SA 4.0 |