Home  >  Q&A  >  body text

Nginx: One IP, multiple websites, how to configure?

One IP, multiple websites, how to configure?

ubuntu 14.04 nginx 1.80 php5-fpm

When a website is working normally, when adding another configuration file to sites-available, all of them are inaccessible. Please tell me how to configure it correctly

習慣沉默習慣沉默2713 days ago741

reply all(5)I'll reply

  • 怪我咯

    怪我咯2017-05-16 17:23:47

    Configure virtual host:
    You can refer to my blog: http://xxgblog.com/2015/05/17/nginx-start/ 4. Virtual host

    server {
        listen 80 default_server;
        server_name _;
        return 444; # 过滤其他域名的请求,返回444状态码
    }
    server {
        listen 80;
        server_name www.aaa.com; # www.aaa.com域名
        location / {
            proxy_pass http://localhost:8080; # 对应端口号8080
        }
    }
    server {
        listen 80;
        server_name www.bbb.com; # www.bbb.com域名
        location / {
            proxy_pass http://localhost:8081; # 对应端口号8081
        }
    }

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:23:47

    Each website runs a different port and then reverse-proxyes to each port through the domain name
    For example,
    abc.com is in 3001
    xyz.com is in 3002

    nginx runs 80 and reverse proxy to 3001 and 3002 according to the domain name

    The idea is here, the specific configuration of the search engine

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 17:23:47

    It is to configure different servers, and then server_name corresponds to the domain name of the website.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 17:23:47

    A vhost profile can be set up for each website. You can use port 80.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:23:47

    Add vhost

    reply
    0
  • Cancelreply