[Fixed]-Set up a test Url configuration on local machine

1đź‘Ť

The hosts file only takes care about hostname resolution. It does not do anything with the ports in use. So your site will be available on http://myname.example.com:8000

Possible ways to have your site running under http://myname.example.com

runserver

In order to use “privileged” ports your process needs to run as root user. When using virtualenv you also have to specify tha path to the respective python binary:

sudo /your/virtualenv/bin/python manage.py runserver 0.0.0.0:80

nginx

Install nginx (or apache) and setup a minimal reverse proxy:

# nginx config
server {

    listen 80;
    server_name myname.example.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }
}

ssh

Use port forwarding locally via ssh. Here again you need root privileges to bind ports below 1024. The following command forwards connections to port 80 on 127.0.0.1 to port 8000 on 127.0.0.1

sudo ssh -L 80:127.0.0.1:8000 <your_user>@127.0.0.1
👤ohrstrom

0đź‘Ť

I don’t know much about Django projects, but as regards setting up a test URL connection to your local-host IP with your chosen domain name, you can do that by using the BIND software, configure your zones and your domain name as the myname.example.com, or if you already have one, create your local zone file to include your local Ip machine number so that way you can “nslookup 127.0.0.1” and your domain name which should resolve to the same name if you look up the IP and vice versa(that is nslookup myname.example.com should resolve to 127.0.0.1), the easier way to do it would be to open your host hile (etc/host/ add myname.example.com beside your 127 Ip address) then go the resolve.conf file and also put in the same parameters. The second stage would be to use apache as your web directory and configure your sites enabled with the same information. then on your chosen port 8000, put the information for the URL link in your Var/www directory and bind it to port 8000. That way when you open your browser with 127 Ip or myname.example.com, you should see the message it works! letting you know your domain is available, once you append the 8000 to the URL link you should see the information you copied and bound to your domain at the specified port. This is off the top of my head, so you would need reference materials if you choose to follow the specs to meet your system distro and configs. But that’s pretty much the basic Idea of setting up a URL link.

👤OlaB

Leave a comment