zoukankan      html  css  js  c++  java
  • linux nginx配置*

    查找  find / -name nginx.conf

    [root@test ~]# cd /etc/nginx/conf.d
    [root@test conf.d]# vi   /usr/local/nginx/conf/nginx.conf
    [root@test conf.d]# vi nginx.conf
    [root@test conf.d]# find / -name nginx.conf
    /etc/nginx/nginx.conf
    [root@test conf.d]# vi /etc/nginx/nginx.conf
    [root@test conf.d]#
    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        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  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
        server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  _;
            root         /usr/share/nginx/html;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location / {
            }
    
    "/etc/nginx/nginx.conf" 90L, 2469C

    上面得到原始的  配置文件

    修改文件后

    server {
    
            listen       80;
    
            server_name  www.xxx.com; #代理服务器本机的域名或者IP
    #charset koi8-r; #access_log logs/host.access.log main; 
    location
    / {
    root html;
    index index.html index.htm;
    proxy_pass http:
    //www.xxx.com;
    }

    :qw 回车

    [root@test ~]# nginx -s reload 
    [root@test ~]# vi /etc/nginx/nginx.conf
    [root@test ~]# vi /etc/nginx/nginx.conf
    [root@test ~]# nginx -s reload 
    [root@test ~]# 

    重启 nginx

    nginx -s reload 

    2.添加多个一个路由,注意:这里 buy必须是域名下对应的文件夹路径

    location /buy { 
       root html; 
      index index.html index.htm;
       proxy_pass http://www.xxx.com;  
    }

    当访问 http://n2.xxxxx.cn/buy 则是第二个

  • 相关阅读:
    shell 实现word count
    jvm 参数调优
    Java注解处理器(转)
    JVM -XX: 参数介绍(转)
    如何在Linux下重命名多个文件
    Kafka学习之broker配置(0.8.1版)(转)
    linux 历史命令用法(转)
    hive-site.xml 参数设置
    Hadoop-2.2.0 + Hbase-0.96.2 + Hive-0.13.1(转)
    正则表达式通过Unicode属性匹配
  • 原文地址:https://www.cnblogs.com/panjinzhao/p/14296752.html
Copyright © 2011-2022 走看看