找到 nginx.conf文件,在其 中配置多个server即可,如:

想监听8080端口,则在nginx.conf配置文件中,在http{}内的末尾处,添加server即可,要添加的内容如下:

listen                 待监听的端口号;

server_name    ip地址

root                   文件路径

index                 索引文件名

 

//新添加  监听8080端口
        server{
                listen 8080;
                server_name 47.101.203.181;
                root /root/rtsp/mec;
                index index.htm index.html;


                location ~* ^.+\.(exe|txt){
                        root /root/rtsp;
                }
        }

 

添加后:

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        server{
                server_name 47.101.203.181;
                root /root/rtsp;
                index preview.html;

                location ~* ^.+\.(exe|txt){
                        root /root/rtsp;
                }
        }

//新添加  监听8080端口
        server{
                listen 8080;
                server_name 47.101.203.181;
                root /root/rtsp/mec;
                index index.htm index.html;


                location ~* ^.+\.(exe|txt){
                        root /root/rtsp;
                }
        }

}

 

 

参考:https://www.linuxidc.com/Linux/2018-02/150722.htm

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐