Nginx: One IP, multiple websites, how to configure?
習慣沉默
習慣沉默 2017-05-16 17:21:47
0
5
788

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

習慣沉默
習慣沉默

reply all(5)
刘奇

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
    }
}
伊谢尔伦

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

左手右手慢动作

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

仅有的幸福

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

曾经蜡笔没有小新

Add vhost

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template