Home > Enterprise >  Django : stop access to my web app from being accessed on port 8000 and access only using the IP
Django : stop access to my web app from being accessed on port 8000 and access only using the IP

Time:05-08

I have deployed my Django web app on a digital ocean droplet. The python server is running on port 8000.

python manage.py runserver 0.0.0.0:8000

I have configured apache web server to serve the requests.

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /etc/myproject

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        #Serving static files
        Alias /static/ /etc/myproject/static/
        <Directory /etc/myproject/static>
                Require all granted
        </Directory>

        <Directory /etc/myproject/myproject>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>
        WSGIDaemonProcess myproject python-path=/etc/myproject python-home=/etc/myprojectenv
        WSGIProcessGroup myproject
        WSGIScriptAlias / /etc/myproject/myproject/wsgi.py
</VirtualHost>

Now when I am accessing my web app using the IP address X.X.X.X, I am able to see my app, however the app is also accessible on port 8000, X.X.X.X:8000.

I want to prevent my app from being accessed on any other port except being accessed ousing IP. How can I do that?

CodePudding user response:

Okay I was missing a point here that I don't need to run Django server as well when I have configured Apache web server to serve my requests. All request are served by the mod_wsgi Apache module. The mod_wsgi package provides an Apache module that implements a WSGI compliant interface for hosting Python based web applications on top of the Apache web server.

  • Related