linux - 测试没有域名的nginx

标签 linux django ubuntu nginx

enter image description here

我正在处理 https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04 .我已经到了最后,按照指示启动了 uwsgi 和 nginx。 据我所知,我已经能够完成所有步骤,包括 uwsgi。

我的测试 django 站点在/home/deploy/sample 中,如屏幕截图所示

如果我

 sudo vim /etc/nginx/sites-available/sample

我明白了:

server {
listen 80;
server_name sample.com www.sample.com;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /home/deploy/sample;
}

location / {
    include         uwsgi_params;
    uwsgi_pass      unix:/run/uwsgi/sample.sock;
}
}

在“安装和配置 Nginx 作为反向代理”下,文章指出:

Inside, we can start our server block by indicating the port number and domain name where our first project should be accessible. We'll assume that you have a domain name for each:

我还没有设置域,但我想在浏览器中打开我的 VPS 的 ip 地址以查看测试站点。

我怎样才能做到这一点?

最佳答案

您可以只使用您的 VPS 的 ip 代替“sample.com”:

server {
    listen 80;
    server_name <your_ip_address>;

    <other stuff>

}

如果您还没有,您可能想要分配一个静态 IP;我相信 Digital Ocean 会给你一些免费的。

关于linux - 测试没有域名的nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41751306/

相关文章:

linux - 读取txt文件并将值解析为bash脚本

linux - 如何制作可以在 api 程序上执行常规工作的图形脚本

linux - 排序内存不足

python - 在 django 2.2 中从 data-url 获取 id 时出现问题

python - ImageSpecField 对 django-rest-framework 中的 django-imagekit 什么都不做

css - 来自 Django 数据库的动态 LESS 变量

c - Linux 模块 : performance counter does not work

创建时的 Ubuntu 组文件权限

spring-boot - 为 Spring Boot 应用程序创建具有命名/主机卷的 Docker 镜像

ubuntu - Ubuntu已连接AD,但无法登录