Limit Heroku Website To Certain IP Addresses - python

Using Python and Flask is there any way to limit my web app to certain IP addresses?
To be more specific, I would like to access my Heroku app via the internet from only specific devices.

You can do what is suggested here with Flask though I agree with the other comments on that post that this should really be done at the networking level. That cannot really be done on Heroku unless you use Private Spaces which has the Trusted IPs feature.

Related

Running Django in IIS

I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?

Python - Deploying Voilà ways

I have created a python notebook with many widgets connected to many dataframes and I can deploy it fine with Voilà on my local host. I would like to understand what is in the simplest way possible I can share the link with people on my internal network and also outside.
I read my articles suggesting to use Heroku, Binder (with GitHub), Google App Engine, PythonAnywhere...
So my question is what do you suggest for my needs? I would like to keep the interface generated with Voilà and I was hooping not to share it public or at least not to everyone.
Thank you
There are services which allow you to 'essentially' put your localhost on the web i.e. they allow people to remotely access a website hosted as localhost on your machine. I have personally used https://ngrok.io. I've also heard of localhost.run which is a recently launched service. With these services, you will get a URL that you can now send to the folks who you would like to access your service. If you do this, your local machine (the one hosting the service) has to be on.
You can also go with the option of deploying to a host like Google App Engine (GAE), PythonAnywhere, Heroku, etc. But you should add some form of authentication so that access is only granted to those who provide that authentication.

Add firewall rules on GCE for an application deployed on GAE

My post has been considered as a duplicate, but this is not...
This question How to access mongodb on GCE with GAE does not answer to how can I edit firewall rules of GCE for an GAE application. It mentioned only about how can how to get te URI to set on an app running on GAE.
This is not my issue. I'd like to make a firewall rule for a deployed GAE application, I already have the external IP of my GCE set on my GAE app.
For example : on my GAE server I can make a dig to get the local server IP (for example : 35.187.8.45), so I can add it to my GCE firewall rules, then in my GAE shell I can make a "python main.py" and access to my mongodb on GCE.
But when I run a "gcloud app deploy", it does not run on the same server anymore. So I have to know on which one to edit a new firewall rules and allow the deployed application.
Hope to be clearer this time...
Well, I finally find a way to achieve what I wanted.
The way to go is to create a GAE flexible, thus, I can find under Instances my diffent VM which have an IP and add them to my GCE (where is my MongoDB) firewall rules.
What I understand of it, but maybe I'm wrong, is in flexible environement, application of GAE is deployed in several VM, running on compute engine, which is not the case for standard environement.
So, for people needs same, and doesn't want to expose their app to whole internet (0.0.0.0/0), go to a flexible environement

Dash/Flask - Deployment of an application on my own server

I am a newbie in web development, I am an energy engineering student trying to make a project, so I apologize if I say something weird.
I've made an application using Dash (python). And now, I would like to deploy that app in my server. I have a remote server (debian, adress.com, IP, opened ports: 80 and 443...) with my ssh public key and all the required stuff.
I have read all the official documentation in the plotly dash page, and also in flask's, but I dont understand very well the thing. I need either Heroku, OpenShift... And I dont understand very well how them work.
Could you please recommend me an easy tutorial (for dummies!) or give me advices/examples about the deployment? I would really apreciate I've searched the Internet a lot, but I can't figure it out.
You describe two options:
1. using your own server to host your app and
2. using a service which will host your app (heroku, etc.)
Using your own server to host your app
You need to decide for a web server, which is serving your page on your server. A host will not magically answer on any port. There is for example apache, nginx, etc... After having chosen one, you need to find a tutorial: how to run your flask app on [yourwebserver] or something like that.
Suppose you have chosen apache, you will find something like this:
https://jackhalpinblog.wordpress.com/2016/08/27/getting-your-python-3-flask-app-to-run-on-apache/
(In this case, you will have to figure out how to run your flask app with python3 instead of python2, if you are running debian)
When your page serves your page, you need an ssl certificate in order to make use of your domain. An easy way of doing this is https://letsencrypt.org/getting-started/ (there are probably other similar services)
Using a service, which will host your app for you (heroku, etc.)
Alternatively do not host you app on your own server, but on heroku, aws, gcd, etc., in my opinion this is much easier than hosting it on your own server. The documentation on hosting service websites is normally very good.
For heroku a good starting point would be here:
https://devcenter.heroku.com/articles/getting-started-with-python. Nevertheless the other services are easy to use as well, i just use this as an example.

Is there any thing needed for https python web page

I been using python to create an web app and it has been doing well so far. Now I would like to encrypt the transmission of the data between client and server using https. The communication is generally just post form and web pages, no money transactions are involve. Is there anything I need to change to the python code except setting the server up with certificate and configurate it to use https? I see a lot of information regarding ssl for python and I not sure if I need those modules and python setup to make https work.
Thanks
Typically, the ssl part for Python web app is managed by some frontend web server like nginx, apache or so.
This does not require any modification of your code (assuming, you are not expecting user to authenticate by ssl certificate on client side, what is quite exotic, but possible scenario).
If you want to run pure Python solution, I would recommend using cherrypy, which is able providing rather reliable and performant web server part (it will be very likely slower then served behind nginx or apache).

Categories