ngnix的配置 映射到同一服务器不同端口和不同域名

2020-01-02  本文已影响0人  zz云飞扬

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

  worker_connections  1024;

}

http {

  include       mime.types;

  default_type  application/octet-stream;

  #log_format  main  '$remote_addr - $remote_user [$time_local]  "$request" '

  #                  '$status  $body_bytes_sent "$http_referer" '

  #                   '"$http_user_agent" "$http_x_forwarded_for"';

  #access_log 

  logs/access.log  main;

  sendfile        on;

  #tcp_nopush     on;

    #keepalive_timeout  0;

  keepalive_timeout  65;

  #gzip  on;

server {

listen       80;

  server_name  localhost;

  #charset koi8-r;

  #access_log 

  logs/host.access.log  main;

  location / {

            root   html;

            index  index.html index.htm;

  }

}

  server {

  listen       81;

  server_name  localhost;

  #charset koi8-r;

  #access_log 

  logs/host.access.log  main;

  location / {

            root   html-81;

            index  index.html index.htm;

  }

 }

    server {

        listen       80;

        server_name  www.taobao.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {

            root   html-taobao;

            index  index.html index.htm;

        }

    }

    server {

        listen       80;

        server_name  www.baidu.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {

            root   html-baidu;

            index  index.html index.htm;

        }

    }

}

host中域名的配置:(上文中ngnix的配置 taobao和baidu其实是在同一台机器的同一个端口程序)

192.168.102.148 www.taobao.com

192.168.102.148 www.baidu.com

上一篇 下一篇

猜你喜欢

热点阅读