How to assign a local IP address to a public IP/Port address using NGINX with UWSGI?

Viewed 51

I have a web application that is running in a local server using a local IP address and the port 80. However, I would like to be able to access the web application from the Internet. Thus, I have got a public a IP address from a telecommunication company. I have configured the NGINX server as followed:

upstream django {
        server unix:///my_path/my_project.sock; 
        # server 127.0.0.1:8000;
    }
    
    # configuration of the server
    server {
        # the port your site will be served on
        listen      80;
        # the domain name it will serve for
        server_name local_ip_address;
        charset     utf-8;
    
        # max upload size
        client_max_body_size 75M;
    
        # Django media
        location /media  {
            alias /my_path/media;  
        }
    
        location /static {
            alias /my_path/static;
        }
        location / {
            uwsgi_pass  django;
            include     /my_path/uwsgi_params; 
        }
    }

In my setting.pyfile, I have used the local IP address in the ALLOWED_HOSTS = ['local IP address']. But in my firewall, I have forwarded this IP to the public one. I have done all the nginx configurations. When I run the application from the local IP address, it is working perfectly, but I run the application from the public IP, it is showing page not found. How can I assign the local IP address to the public one? Please, assist.

0 Answers
Related