Using IIS to show Bokeh dashboard - python

I am new to Internet Information Services for Windows. I have a Bokeh dashboard ready and I can serve it using the terminal and the command
bokeh serve app_myapp/ --port 5200 --allow-websocket-origin=my_IP_address
In IIS, I have set up the Host Name (xx.yyy.com) and the Port (80), and the Physical Address is C:\inetpub\wwwroot\some_blank_htm_file
Currently xx.yyy.com shows my blank file, but I don't know how to connect serving my bokeh dashboard with IIS settings.
I would greatly appreciate any help.

Do you mean you want to show the bokeh dashboard when you use xx.yyy.com address?
In my opinion, the most easily way is using the IIS url rewrite to achieve your requirement.
You could install it from this url.
Then you could redirect all the request to the port 5200 by using below config setting.
<rewrite>
<rules>
<rule name="Reverse Proxy to webmail" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:5200/{R:1}" />
</rule>
</rules>
</rewrite>
More detials about how to use reverse proxy, you could refer to this article.

The goal is to use IIS as a reverse proxy. IIS is not a reverse proxy by default, so we have to add some modules and then start the configuration. These are all the steps I took:
Install the URL Rewrite package from the Downloads section on the IIS website.
Install the ARR (application request routing) module from the Downloads section on the IIS website.
In IIS, under sites, add a new website and set the Host Name to your FQDN. Also, Choose a Site Name and a Physical Path (I think it doesn't matter what.) and click OK.
In the left pane, double-click on the website you created. In the modules, double-click on URL Rewrite, then click on Add Rule(s), choose Reverse Proxy and click OK. Then in the new window type 127.0.0.1:my_bokeh_port and hit OK.
From the left pane, double-click on the main tree node with your server name on it, and from the modules, double-click on Application Request Routing Cache. In the right pane, choose Enable proxy, and set HTTP version to Pass through.
Use this guide to set Server Farms. Honestly, I'm not really sure if this step is necessary, but since I had done it before some of the former steps I just mentioned, I thought it might be.
Close and restart IIS.
Now, if you go to your website in your browser, you will probably see your address (for example x.y.'com') change to x.y.'com'/app_myapp. If you can also see your dashboard, then that's all. If not, however, it means that your firewall is blocking the WebSocket connection. You can use this guide to allow a TCP connection to your Bokeh port.
Hopefully, now you can refresh and see your dashboard.

Related

Controlling Kodi from Browser

I am currently building a media website using node js. I would like to be able to control Kodi, which is installed of the server computer, remotely from the website browser.How would I go about doing this? My first idea was
to simply see if I could somehow pipe the entire Kodi GUI into the
browser such that the full program stays on the server
and just the GUI is piped to the browser, sending commands back to
the server;
however, I could find little documentation on how to do that.
Second, I thought of making a script (eg Python) that would be able to control Kodi and just interface node js with the Python script, but again,
I could find little documentation on that.
Any help would be much appreciated.
Thank You!
Can't you just go to settings -> services -> control and then the 'remote control via http' settings? I use this to login to my local ip e.g. 192.168.1.150:8080 (you can set the port on this page) from my browser and I can do anything from there

Django local server stopped working

As far as I am aware, nothing in my configuration has changed except my location (network connection) and a minor update to OSX.
I can go back to known working commits in my git repository and still does not work, so I know it's not the project or project settings.
The server is 'running' on 0.0.0.0:8000 and I'm using django-hosts to map urls onto a custom host (blah.blah.org:8000, for example).
Going to the custom host gets me a webpage not available, and going to the 0.0.0.0:8000 actually pings the server, but doesn't do much else (nor should it, because of django-hosts).
How can I debug this?
I think it was something to do with the router configuration I was connected to. I was recommended to just add 0.0.0.0 to the hosts file intercepting my local site, which works fine. If anyone is out traveling around and has the same problem:
http://www.tekrevue.com/tip/edit-hosts-file-mac-os-x/

port forwarding django development server - URL is being doubled

I have a Django development server running on a remote centos VM on another lan. I have set up port forwarding using Secure CRT to access the web page through my browser from my desk pc. I am currently not using apache with the development server and is shutdown.
I start the server by running python manage.py runserver 0.0.0.0:80.
When I type either the ip or www.localhost.com into the web browser, my URL is read as if it has been doubled with the host being read as if it was also the path.
Page not found (404)##
Request Method: GET
Request URL: http://www.localhost.com/http://www.localhost.com/
When I try to access the development server from within the same LAN the page loads up fine.
I have been searching through the django documentation and stack overflow, but I have yet to find a similar problem to this. Does anyone have any thoughts on why this may be happening and what could be a possible solution?
Thank you very much in advance!
It looks like the request URL is incorrect:
http://www.localhost.com/http://www.localhost.com/ should probably be http://actual_machine_IP.com/
I'd start searching there. You won't be able to access the VM's port 80 from a different lan using localhost as the hostname since localhost is probably already set in your hosts file.
If you want to test your dev environ remotely, can I suggest either setting up Apache properly with port 80 (as opposed to using django's dev server--privilege restrictions and all that can be circumvented with sudo and other bad practice) or use a pre-built shared dev service like vagrant share.

Running Node or Python app from a Linux Azure VM

I can't seem to figure this out. I created a new Ubuntu VM on Azure and I can SSH into it. I installed Node (which I've done many times) and I tried to run the test app from nodejs.org:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
However, when I go to the IP (which is the same one I SSHed into the box from) + :1337 it just never loads. I tried :80 too, but still no luck. I also tried running python -m SimpleHTTPServer on :8000 and I still can't view the site. I must be missing something.
Just so you know, I'm just trying to setup a simple dev box with a bunch of projects on it. I want to be able to work on my projects anywhere. Some are 100% front-end JS projects so SimpleHTTPServer would be fine. Some are Node projects too. In either case, I just want to be able to hit some port and see what I'm working on.
Oh also I opened up the Azure firewall to the VM, redirecting traffic from port 80 to port 1337 (https://www.evernote.com/shard/s5/sh/3aef8e76-04f6-48cb-84f9-32462bc425a7/f0cd749773a9d09cee66d00fe3e707c0)
You are listening loopback ip address. Try .listen(1337, '0.0.0.0'); to listen on all network interfaces
urgh azure. i cannot get port 80 open. is it the machine iptables?? some azure magical thing.
i know it cant be that hard.
unlike your view i do not see 'NONE' for load balancer. i see '--'/ whatever that means.

django-social-auth : How to redirect example.com to 127.0.0.1:8000?

I am sure many Django developers must come across this issue when using the social-auth.
Initially when you develop it, you would like to test it on your local server, hence you would redirect the domainname in your etc/hosts.
I came along this in the documentation:
https://github.com/omab/django-social-auth#facebook
If you define a redirect URL in Facebook setup page, be sure to not
define http://localhost:8000 because it won't
work when testing. Instead I define http://myapp.com and setup a
mapping on /etc/hosts or use dnsmasq.
From my understanding you can not define any ports in /etc/hosts.
Hence defining this entry there:
127.0.0.1 example.com
still doesn't hit my Django server that runs at 127.0.0.1:8000.
How do you guys do this?
Thanks,
Everyone says, "add example.com to your hosts file..." but neglects to mention that you should use example.com:8000 after starting the runserver. Here are more detailed steps that worked for me:
On linux:
open a terminal
sudo gedit (or replace gedit with the text editor of choice)
Open the etc/hosts file
add a line: 127.0.0.1 example.com (if you already have a line starting with 127.0.0.1 you can leave it - https://serverfault.com/questions/231844/is-it-safe-to-add-additional-127-0-0-1-entries-to-etc-hosts)
save the file
start your django dev server - python manage.py runserver
open a browser and go to example.com:8000 (this gives the correct callback to google and other sites that will not work with 127.0.0.1 or localhost)
You should see the home page of your django site.
Go to the social site you want to connect with and set up your client ID, using example.com as the website name. For example, the callback url for google is http://example.com:8000/complete/google-oauth2/
Copy the appropriate key/id settings and paste into your SETTINGS.py
Now your dev server should work!
I know this is an older post, but I could not find the complete steps anywhere. Please add clarifications if necessary as I am not an expert with this.
I have solved the redirection problem by following the steps here: https://serverfault.com/questions/397364/how-to-setup-named-virtual-hosts-in-nginx
In short, you need an entry in /etc/hosts as I have above plus nginx proxy between.
Install fiddler. Once installed, go to tools > Hosts.
Then you can map from 127.0.0.1:8000 to mysite.com
The following finally fixed it for me...
Under Authorized JavaScript origins: http://localhost:8000
Under Authorized redirect URIs: http://localhost:8000/page-name-here
If any of you guys is still struggling after adding 127.0.0.1 mysite.com to /etc/hosts, check whether you're using a VPN. I was still getting the error, "Unable to connect to mysite.com:8000". I resolved this error by turning off my VPN.

Categories

Resources