Home  >  Q&A  >  body text

django - nginx cannot use port 80 (it will automatically jump to the welcome interface of nginx), other ports can be used

/etc/nginx/sites-enabled/mysite.conf listens to port 80

server {
    listen 80;
    server_name localhost;

    location /static {
        alias /home/alps/mysite/blog/static;
    }

    location / {
        uwsgi_pass 127.0.0.1:8001;
        include     /etc/nginx/uwsgi_params;
    }
}

localhost:80 It will jump to the nginx default interface instead of the welcome interface of my django project

my question


1. 结果浏览器里面访问localhost:80它会自动跳转到nginx默认的欢迎界面
2. 但是如果监听8080这些端口,localhost:8080可以跳转到正确的界面
3. 请问这是怎么回事呢?我应该如何设置?
ringa_leeringa_lee2714 days ago571

reply all(9)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-16 17:15:02

    It should be occupied by /etc/sites-enabled/default. Try removing the configuration or changing the port.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 17:15:02

    Visual inspection, the configuration file is written in the wrong place?

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:15:02

    It’s because your project directory has not been written,
    this parameter

    root /home/www

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 17:15:02

    location  / {
        include     /etc/nginx/uwsgi_params;
        uwsgi_pass  127.0.0.1:8001;
        uwsgi_param UWSGI_SCRIPT    <__DJANGO_PROJECT__>.wsgi;
        uwsgi_param UWSGI_CHDIR     /<__DJANGO_HOME_DIR__>;
        index       index.html index.html;
        client_max_body_size        35M;
    }

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:15:02

    Has nginx been restarted?

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:15:02

    I have encountered this problem before. . Finally, it was discovered that the server's system's own nginx occupied port 80. . Just uninstall it.
    You can judge like this: lsof -i:80
    See which process is occupying it, then kill or uninstall it, and then start your own

    reply
    0
  • 黄舟

    黄舟2017-05-16 17:15:02

    nginx.conf has a default configuration of 80. If you don’t use the default configuration, add the domain name yourself and change hosts to access.

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 17:15:02

    Why is it you again? You’ve been working on it for a week and you haven’t succeeded yet

    reply
    0
  • 迷茫

    迷茫2017-05-16 17:15:02

    Another configuration file is introduced in the configuration item

    include /etc/nginx/conf.d/*.conf;

    Comment out

    That’s it

    reply
    0
  • Cancelreply