I'm using django, uwsgi and nginx. I have tried nginx and django documentation for serving static files. My conf file is:
http {
upstream django {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name 192.xx.xx.x;
root /path/to/project/;
location /static/ {
alias /path/to/static/;
}
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass django;
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}
}
}
Is my config file true? Can I use IP Address in server_name
section? (IP Address is my machine IP)
Per https://nginx.org/en/docs/http/ngx_http_core_module.html#server:
An overview of how nginx processes requests can be found at https://nginx.org/en/docs/http/request_processing.html, and an overview of serving static content can be found here: https://www.nginx.com/resources/admin-guide/serving-static-content/.
There is nothing I can see in your config that would prevent things from working - did you test your config and run into any issues?
Yes you can change servername as machine IP address to serve django application, the extra effort is, you have to assign host variable as IP address in settings.py file of your application.