Host a Django project on Apache2 locally - python

I have finished a Django project and want to deploy it over Apache2 locally over LAN. I have figured out how to connect Django with Apache2 using mod_wsgi and it worked great because I was able to use Apace2 to actually host Django on localhost.
Now I want to actually make this project available to anyone on my local network. Like for instance assuming that my local IP address was 10.10.10.51 I could go to a different device connected to my local network and type in 10.10.10.51 to actually get to the Apache2 server homepage. It does that successfully.
My Django project is hosted on my Apache2 localhost server at djangoproject.localhost and it works fine just on my PC. When I move on to the other PC and go to djangoproject.localhost the site is not up there. Yes they are both connected to the same LAN network.
I used this tutorial to host Django on Apache2: Host Django on Apache2 with mod_wsgi

I think that you have to configure something called port forwarding in your home modem, this video could help: https://www.youtube.com/watch?v=6gkoDQUQSLc

I suppose you are on windows ...
If you run your app on pc1 and want to call it from pc2, you need to call it either
via ip adress of pc1
via djangoproject.localhost
but then you need to edit the hosts file on pc2:
C:\Windows\System32\drivers\etc\hosts
and add something like (x.x.x.x = ip adress of pc1)
x.x.x.x djangoproject.localhost
because on pc2 your brwoser does not know what to do with djangoproject.localhost as in a LAN in general you do not have a local domain name server running.
If your firewall on pc1 blocks access to apache you need to got to "windows defender firewall" (type "defender" in search bar) and add a rule for apache application.

Related

Django, RestAPI, Microsoft Azure, website, virtual machine, ubuntu

I have developed a website and REST api using Django and Django REST Framework. On local machine they are working perfectly so my next step is trying to publish it on remote server. I chose Microsoft Azure.
I created a virtual machine with Ubuntu server 18.04 and installed everything to run my project there. While I run it locally on virtual machine it's working perfectly, at localhost:8000; my website and rest-api are showing.
Now I want it to publish to the world so it can be accessed under the IP of my virtual machine or some different address so everybody can access it. I was looking through azure tutorials on Microsoft website and google, but i cannot find anything working.
I don't want to use their Web App solution or Windows Server. It needs to be working with Ubuntu Virtual machine from Azure. Is it possible to do and if yes then how?
(Optional) Set your web application listen publicly on 80 port for http or 443 port for https. You may refer to: About IP 0.0.0.0 in Django
In Ubuntu OS, if firewall is enabled, you need to open port 80 and 443, so that others can access your server.
In Azure portal, if NSG is enabled, you need to add inbound rules for 80 and 433.
(Optional) Buy a domain, and add an A record to your VM's IP. In this way, people would be able to access your website via friendly URL.

Node.js runserver on GCP Virtual Machine

I have a python application hosted by a node.js frontend. I am running that on a linux vm on Google Cloud virtual machine (GCP).
node appname runserver 8080 command starts local server within VM but I am wondering what would be step by step process to access it via a DNS from outside world.
Or if there is better approach to host python ML applications behind a web interface, then please suggest.
You need to use forever for this.
Forever will move the node process to the background and service will keep running in the background even if you log out of the server. And In order to access from outside point a DNS domain to this IP address of the machine and then Proxy Pass the request on port 80 to the port your service is running on.
Then you will be able to access it via domain name.
Look for ProxyPass directive in the Http server. That would work for you. :D

How to deploy a wep abb within my work network?

I created an API for the company i work however i would like people having access in the same company network, how can i achieve this? I currently modified the allowed host as follow:
ALLOWED_HOSTS = ['127.0.0.1', 'localhost','192.168.6.7', '127.0.1.1', '161.19.109.123']
however only work in my computer under IP: 127.0.0.1:8000, any suggestions? FYI i do not have administrator privilege.
Try this to access project in a lan server
python manage.py runserver your_ip:port.
For example
my system IP address is something like 192.168.12.135, when we run run django development server its runs at localhost:8000, i mean with the system IP address and with a port 8000 like 192.168.12.135:8000 right.
it'll be accessible if you're running through apache or any other webservers other than the development server.
I would advice you to host and use a local apache server rather than using development server. Doing so, you can foresee the issues you'll be facing when moving to production.

Django - Host a website on a Lan Network

I've been working on a website for the past month, and now its time for me to host the django website onto a private server. Is there a detailed method on how I'm supposed to host the website onto a specific IP address assigned to my system?
This is my first time dealing with hosting a server and i dont know much about it.
Also, once i host it, How do i change the link from being the IP address to an actual link like "12345678.com" or something like that?
(The website should be hosted in such a way that only the people who are in the same network/lan connection should have access to the website.)
I have wamp on the system and the system has a Windows Server OS (if this info helps)
you can run your codes with manage command like this
python manage.py runserver 0.0.0.0:8000
but its strongly recommended to run your code with a web server like nginx or apache read this tutorial to run your site on a linux server
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04
on windows you can use IIS but its not recommended. its performance is not good
to use 1234567890.com instead of using server ip address you must setup a DNS server on your local network. in linux you can use bind and windows server have its own DNS server. but in your DHCP configuration you must set this DNS server as clients DNS.

Why can’t Internet Explorer access my Django Development Server that’s accessible externally (i.e. not on localhost?)

I've been tasked by my programming teacher to learn Django. However, I need to code on a command line linux box and therefore cannot access the web page from said linux box.
To test, I need to host it on the local IP of the computer rather than localhost. I’m currently running the Django development server using this command:
python manage.py runserver 0.0.0.0:8000
Firefox and Chrome can access the development server at the Linux box’s IP address, but Internet Explorer can’t.
Unfortunately (I am said teacher), I can't provide a linux host - only a linux server and a windows host to do development on.
He's actually running the web server correctly, with the command provided by Paul. But for some reason, it's only visible in Firefox/Chrome, IE just provides a generic "Webpage cannot be displayed"
But this problem can be solved by using the entire address: http:// isn't optional like it is in Chrome and Firefox.
When you run the development server, you can make it available on the local network by specifying the IP address 0.0.0.0 for it, like this:
python manage.py runserver 0.0.0.0:8000
If your Linux box’s local IP address is e.g. 192.168.1.37, you’d access the development server at:
http://192.168.1.37:8000
Setup nginx to listen on a public port and proxy all of the requests to the django runserver.
You need to specify the IP clearly in the command line like this in order to let other clients to access. You also have to enable the port 8000 in the firewall:
python manage.py runserver 192.168.1.37:8000

Categories

Resources