zoukankan      html  css  js  c++  java
  • nginx 同一 iP 多域名配置方法(多文件)

    一、Nginx 配置文件(nginx version: nginx/1.12.2)

      路径:/usr/local/nginx/conf/nginx.conf

      操作:在 http 模块增加(子配置文件的路径和名称):include vhost/*.conf;  

    user root;
    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;
    	
        include vhost/*.conf;
    
    
        
    }
    

      

    二、Nginx 子配置文件

      路径:/usr/local/nginx/conf/vhost

    [root@VM_2_29_centos vhost]# ls
    xieboke.net.conf  zhuoqun.info.conf

      子配置文件例子:对于 http,直接 把想要的域名 加载 server_name 后面,空格间隔;对于 https, 要配 ssl 证书路径,再复制一份改下 server_name 和 ssl 证书位置就行。

    [root@VM_2_29_centos vhost]# cat xieboke.net.conf 
    server {
            listen       80;
            listen       443;
            server_name  xieboke.net;
            charset utf-8;
    
            ssl on;
            ssl_certificate      /root/yzq/ssl/xieboke.net/1_xieboke.net_bundle.crt;
            ssl_certificate_key  /root/yzq/ssl/xieboke.net/2_xieboke.net.key;
    
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            ssl_ciphers  HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
    
    	access_log  /root/yzq/logs/xieboke.net.access.log;
    	error_log   /root/yzq/logs/xieboke.net.error.log;
    
            location / {
                 uwsgi_pass 127.0.0.1:9090;
                 include uwsgi_params;
        #        root   html;
        #        index  index.html index.htm;
            }
    
    	location /media {
    		alias /root/yzq/djangos/blog/media;
    	}
    
    	location /static {
    		alias /root/yzq/djangos/blog/static_root;
    	}
    
     }
     


    三 、重启 Nginx

      nginx -s reload

      

  • 相关阅读:
    如何为基于windows验证的站点的某个页面、文件或文件夹单独设置匿名访问
    JMeter基础
    selenium select操作及其他补充
    HTML面试
    第一天
    AspNetPager 7.4.2版发布
    java移位运算copy来的。为了备忘
    android 开发中的错误
    启动android模拟器报错
    最省内存的方式加载图片资源
  • 原文地址:https://www.cnblogs.com/yinzhuoqun/p/10951857.html
Copyright © 2011-2022 走看看