I'm using the bottom piece of code for my program http://webpy.org/cookbook/ssl and when I connect to my python server through https all is well. Then when I go to connect to my server as http it does not connect as expected.
But then when I go back to https I get a time out every time and I have to restart my comp so I can connect again.
Can anyone help me with where to start on this problem?
Thanks.
In your nginx, or apache server configuration file, you need to redirect the page to https all the time, or handle the http properly. for example if somebody hits my server I permanently redirect to the https every time like this in Nginx:
server {
listen 80;
rewrite ^ https://$host$request_uri permanent;
}
You will also need to define your webpy application handling. I ended up using Ubuntu, Nginx, uWSGI with webpy and my site works really well. Hopefully this helps. I was doing the exact same thing as you until I found this site:
http://fartersoft.com/blog/2012/02/10/deployment-of-web-py-applications-using-uwsgi-and-nginx-on-ubuntu/
Which helped me get started. I hope it helps you.
Related
So I have this web application running with Python's Flask and I use gevent.pywsgi.WSGIServer in order to make my application ready for production. My website is accessible from the Internet with all my devices and even others with different networks.
However I tried to add the HTTPS possibility by running the test with certbot letsencrypt... I passed the tests and obtain the certfile and keyfile but when I put them as arguments in the following function :
app_server = gevent.pywsgi.WSGIServer(
(CONFIG['Flask']['host'], int(CONFIG['Flask']['port'])),
app,
certfile="fullchain.pem",
keyfile="privkey_rsa.pem"
)
Well I get this error ssl.SSLError: [SSL] PEM lib.
PS: I opened my port for HTTPS server
That's why I wonder if the problem comes from:
the domain name passed for the letsencrypt test
domain name registrar
...
Or something else?
Thank you in advance.
I know this question is old and I came here looking for an answer to something else, but I have gone through your exact situation and couldn't help answering it.
I actually resolved the situation the proper way of building a website. I registered with a free dns server and routed all traffic coming to my router on ports 80/443 to a virtual machine in the LAN running NGINX, where I had already setup letsencrypt certs. Using this setup I don't have to enable SSL on any other machine in the network. Off topic, but to enable local network level ssl you need to have all the machines in the network. But you can simply forward requests from NGINX to any machine running in your local network using http and to the outside world all the traffic happens over SSL.
NGINX configuration is simple for LAN and you can create one yourself with a little google search, but the basic structure contains one server and several child location blocks where each location block corresponds to one web application in the LAN.
Hope this helps a bit. I can put a more detailed answer with specific steps if you are still looking.
I deployed my flask rest api on IIS 8 to windows server 2012 r2. I followed this article. (https://medium.com/#bilalbayasut/deploying-python-web-app-flask-in-windows-server-iis-using-fastcgi-6c1873ae0ad8) I can browse the rest api on the local server but I can not browse the api from other computers on public internet. I can ping the public IP of the server without problem. There is no firewall rule that blocks the server. Would you please help me?
PS. I am trying to browse by the IP, 185.201.212.219. Is it related to this?
edit1: I will try this which is from flask documentation.
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
edit2: Adding host parameter didn't work.
Is there any ideas?
Thanks in advance.
All ports except 80 was open. When I set port=80, all my troubles seem so far away :)
I want to make the development server in Django be on the internet while running Windows 10. How can I do this?
By the way, when I try to use my external IP, it doesn't work. It says that I can't use it
While starting the Django Server, mention the IP and PORT from which you want to accept the requests. Mention 0.0.0.0 to open it for all as:
python manage.py runserver 0.0.0.0:80
By default the Django's server accepts requests only via localhost.
Now make a request via using public IP of the system on which your Django's server is running
You can try a deployment on Heroku. Is relativelly easy to set up and provides you with a live server in minutes.
Sorry about the confusion, this is an old question but what actually happened was that I didn't add any port forwarding rules on my router. If I did, then the solutions raised by others would've worked. Since I didn't port forward, I just ended up hosting it on heroku.
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.
I'm working on a ubuntu 12.04 with python, django and recently django-socketio (https://github.com/stephenmcd/django-socketio).
My problem is when I send something to the server through socket and wait for it to send back, when it doesn't.
the django server is running on default http port(80). And the socketio on 8080 port.
if I access my website like this: 'http://mysite.com/' the pages using socketio does not work at all. But using the 8080 port, everything works!
The reason I don't use the socketio server to handle requests(it has a server that you start by typing a manage.py command) is that I don't know how to do it using apache. Got stuck with setting up the wsgi file. What I know so far is that you have to attach the SocketIOServer to django application and whatever. Have tried this, with no success.
My question is: how can I make this work? Maybe having one handling on one port the other on other port should work. But also tried this.
I really don't want to use ajax since is lot's of async requests.
Something, please!
Thanks in advance.