nginx

README.txt

1. 配置
   1)配置文件路径:/conf/nginx.conf
   2)配置项: 
    ① upstream server_list1 {} 定义了远程访问的服务器(项目部署服务器)IP地址, 根据项目部署地址编号可以修改远程服务器地址(当前设置为172.16.16.2:8080)修改时请注意端口号正确
    ② server {} 中定义了 nginx访问时的监听端口,以及访问域名或者说服务器名 (当前分别定义为: listen 82; server_name  localhost;)
    ③ server{}中的 location |regex(这里是正则表达式)|  {} 中定义了资源位置: 当前
        location / {}中定义动态资源访问,使用代理即:(proxy_pass为指定使用代理的关键字)   http://server_list1
        location ~ \.(gif|jpg|jpeg|png|bmp|swf|css|js|html|htm|xml)$ 指定了这些类型的资源访问时转向本地资源,使用本地文件系统的: (root为指定使用以下路径作为根路径)  D:\var\miner;
    访问指定静态资源时会转为访问root配置的目录

2. 启动方式
    1)点击nginx.exe直接启动
    2)命令行:进入cmd后使用cd进入nginx.exe所在目录,start nginx即可启动 nginx -s stop停止运行

nginx.conf

#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;

 ###########################################
 #miner modify begin 201706
 ###########################################
    #webSocket代理需要
 map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
 }
 upstream server_newMiner {
  server 172.16.64.46:8088;
    }
 upstream server_oldMiner {
  server 172.16.64.159:8080;
  #server 172.16.16.2:8080;
    }

 ###########################################
    #miner modify end 201706
 ###########################################
 #in the 'http' block

    server {
        listen 86;
        server_name localhost;

        #charset koi8-r;

        #access_log logs/host.access.log main;

        ###########################################
  #miner modify begin 201706
  ###########################################


  # 配置静态资源由nginx处理 存放目录指定为html
  location ~ \.(gif|jpg|jpeg|png|bmp|swf|css|js|html|htm)$ { 
            root C:\Users\Administrator\Desktop\Miner项目; 
        }
  # 配置.do资源由dataming处理
  location ~ \.(do|xml|srv)$ { 
            proxy_pass http://server_oldMiner;
        }

  #其他所有动态资源请求由此过

        location / {
   proxy_pass http://server_newMiner;

    # 下面是关键
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection $connection_upgrade;
   # 这是配置webpysessoin丢失的问题
   #fastcgi_param SCRIPT_NAME "";
   # Pass the csrf token (see https://de.wikipedia.org/wiki/Cross-Site-Request-Forgery)
   # Default in Spring Boot and required. Without it nginx suppresses the value
            proxy_pass_header X-XSRF-TOKEN;
   # Set origin to the real instance, otherwise a of Spring security check will fail
   # Same value as defined in proxy_pass
   proxy_set_header Origin http://server_newMiner; 
        }

  ###########################################
  #miner modify end 201706
  ###########################################


        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        # proxy_pass http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        # root html;
        # fastcgi_pass 127.0.0.1:9000;
        # fastcgi_index index.php;
        # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
        # include fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        # deny all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}


    # HTTPS server
    #
    #server {
    # listen 443 ssl;
    # server_name localhost;

    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;

    # ssl_session_cache shared:SSL:1m;
    # ssl_session_timeout 5m;

    # ssl_ciphers HIGH:!aNULL:!MD5;
    # ssl_prefer_server_ciphers on;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值