You can open whatever port you want at any time, at your own peril.
Getting back to your question. Myopenhab does not provide a possibility to proxy web pages. It only proxies images.
So if you are serving a web page that you want to view when visiting myopenhab you need to refer to your public IP in the URL instead.
However as noted by the gentleman before me if you use port 8080 where openhab is already being served then you effectively open your openhab up to everyone on the internet, which may not be what you actually want.
Instead you should probably serve the weather page on another server like nginx or something on another port and then possibly open only that port to the internet.
That was a good tip there about using an image. So what I ended up doing was searching a way to convert html to png and since I use Ubuntu came across http://phantomjs.org/ which has a good, easy way to convert the weather to an image. This program phantomjs appears it may also be useful for many things including making your own custom colorwheel, but that’s probably beyond my skill level a this point.
So it it helps anyone else, the basic steps I followed for Ubuntu Server 16 are as follows.
You can see the above will place the image in your ‘html/images’ directory. And you can run the script manually like such:
phantomjs /etc/openhab2/scripts/weather.js
With use of the Exec binding installed and the ExecuteCommand line in a rule, I run the script each time my Weather Min and Max Temps are updated. Note, I am using the WeatherUndground for weather that is set to update temps every 5 minutes, but also have the weather 1.x binding installed strictly for making the html image.
rule "Set daily max and min temperature"
when
Item Wunderground_Temperature changed or
Time cron "0 0 0 * * ?" or
System started
then
val max = (Wunderground_Temperature.maximumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue
val min = (Wunderground_Temperature.minimumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue
if( max != null && min != null) {
Wunderground_Temperature_Max.postUpdate(max)
Wunderground_Temperature_Min.postUpdate(min)
}
//Create Image of the Weather for SiteMap
var cmd = 'phantomjs@@/etc/openhab2/scripts/weather.js'
executeCommandLine(cmd)
end
And then finally in my sitemap I reference the image and can see it both locally and when outside the home
Could you repost this as a separate topic in the Tutorials and Examples section? A lot of people recently have posted about being frustrated getting the old OH 1.x Weather Binding Webview working, particularly in their phone Apps.
This is a good approach to accomplishing that.
And to provide a little more useful information about opening the port.
It is very risky to open an unauthenticated server on the internet. I highly recommend against doing so.
It is very slightly less risky to expose an unauthenticated server on the internet over HTTPS (i.e. port 8443). I highly recommend against doing this.
It is slightly less risky to set up a reverse proxy (see the Security section of the Installation Docs) and expose your OH to the Internet using username and password authentication. This approach can be made relatively safe, but unless you really know what you are doing I highly recommend against doing this. But if you must, this is the minimum one should do.
Honestly, access to Webviews simply does not rise to become an important enough feature to risk opening any of my openHAB ports, even through a reverse proxy, to the Internet.
This is why I usually recommend using myopenhab.org or setting up a VPN.
I want to update this thread because the original solution for creating images does not work on a Raspberry Pi cause of different architecture. After hours of research (I am new to the Raspi-World), I finally found a working phantomjs for ARM.
Kudos to @ptmuldoon for bringing the solution converting the HTML to an image, a superb idea to overcome the limitations of Webview in the app when using remote URL!