如何使用UWSGI使用NGINX将本地IP地址分配给公共IP/端口地址?
我有一个使用本地IP地址和端口80在本地服务器中运行的Web应用程序。但是,我希望能够从Internet访问Web应用程序。因此,我从电信公司获得了公共IP地址。我已经配置了nginx服务器,如下所示:
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;
}
}
在我的sett.py
文件中,我在wasse_hosts = ['local IP地址']
中使用了本地IP地址。但是在我的防火墙中,我将此IP转发给了公众。 我已经完成了所有NGINX配置。当我从本地IP地址运行应用程序时,它可以很好地工作,但是我从公共IP运行了应用程序,它显示的页面找不到。 如何将本地IP地址分配给公众? 请协助。
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.py
file, 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论