Windows installation nginx-1.10.1 reverse proxy access to IIS Web site

Source: Internet
Author: User
Tags sendfile

First go to the official website download package, decompression, the best way not to have Chinese

Path issues for Nginx configuration
Because the file path can be "\" under Windows, you can use "\" or "/" as the path separator. But "\" is most likely to cause problems, so try to avoid using them.

Do not add path, or an error will be raised, config file path cannot be found

Like I unpacked it in e disk.

The cmd command navigates to the Nginx.exe folder CD E:\WorkSoftWare\nginx-1.10.1

Then execute, first ensure that the nginx.conf file configuration is no problem

In fact, Nginx's most important and main job is the configuration file, the other does not need our application developer attention, unless you want to modify the underlying source code.

The nginx.conf configuration is as follows:

#user nobody; 
Worker_processes 1;
#工作进程的个数, multiple #全局错误日志及PID文件 error_log/worksoftware/nginx-1.10.1/logs/error.log can be configured;
#error_log Logs/error.log Notice;

#error_log Logs/error.log Info;


Pid/worksoftware/nginx-1.10.1/logs/nginx.pid;       Events {worker_connections 1024; #单个进程最大连接数 (maximum number of connections = number of connections * processes)} #设定http服务器, leverage its reverse proxy capabilities to provide load balancing support for HTTP {include  Mime.types; #设定配置文件位置, the Conf here refers to the directory where the nginx.conf is located, or you can use the absolute path to specify the configuration file Default_type Application/octet-stream elsewhere;                  #默认类型-8 file stream #设定日志格式 #log_format main ' $remote _addr-$remote _user [$time] ' $request '
    
	"$status $body _bytes_sent" $http _referer "' # '" $http _user_agent "" $http _x_forwarded_for ";

    #设定访问日志 #access_log/worksoftware/nginx-1.10.1/logs/access.log Main;  Sendfile on;  #是否激活sendfile () function is more efficient than the default mode #tcp_nopush on;
    #将HTTP响应头压缩到一个包中发送, #连接超时时间 #keepalive_timeout 0 can be used only when the sendfile is opened;

    Keepalive_timeout 65; Gzip  On
    #启用Gzip压缩 #服务器的集群 #设定负载均衡的服务器列表 supports multiple sets of load balancing, multiple upstream can be configured to serve different servers. 
    #nginx upstream supports several ways of assigning #1), polling (default) each request is assigned to a different back-end server in chronological order, and can be automatically removed if the backend server is down. #2), weight specifies the polling probability, weight and access ratios are proportional to the performance of the backend server.
    With the above sample, the weight is specified. 
    #3), Ip_hash each request is allocated according to the hash result of the access IP, so that each visitor fixed access to a back-end server resolves the session's problem. #4), fair #5), Url_hash #Urlhash #upstream imicrosoft.net #{#服务器集群名字 weight is the meaning of weight, weight
		The greater the probability of allocation. 
        #server 192.98.12.60:1985 weight=3 max_fails=2 fail_timeout=30s;
	    
		#server 192.98.12.42:8086 weight=3 max_fails=2 fail_timeout=30s;     
        #weigth参数表示权值, the higher the weight, the greater the probability of being assigned #1. Down indicates that the server before the single is temporarily not participating in the load #2. Weight defaults to 1.weight, the load weight is greater. #3. Backup: All other non-backup machines request backup machines when down or busy. 		
		So this machine will be the lightest pressure.
	#本例是指在同一台服务器, multiple servers change IP can be # server 127.0.0.1:8055 weight=4 down;
    # server 127.0.0.1:8010 weight=5 backup;
		#} upstream localhost {server 127.0.0.1:9000 weight=3 max_fails=2 fail_timeout=200s; Server 127.0.0.1:8086 weight=5 max_fails=2 fail_timeout=200s;   #当前的Nginx的配置, the address of the proxy server, that is, the server address, listening port, default address of the Nginx installation, #设定虚拟主机, the default is to listen on 80 port server {Listen 9090; #侦听9090端口 #对于server_name, if you need to reverse proxy for multiple domain name requests, you can configure multiple server_name to meet the requirements server_name localhost;
        #当前服务的域名 CharSet UTF8;
      
	    #charset Koi8-r;

		
		#设定本虚拟主机的访问日志 #access_log Logs/host.access.log Main;
		#如果访问/images/*,/js/*,/css/* Resources, take the local file directly, without forwarding. 
		#但如果文件较多效果不是太好. #location ~ *\.
        (jpg|jpeg|gif|css|png|ico|html) $ #{# expires 30d;
        # root/nginx-1.10.1 #root: # break;       #} #对 '/' Enable load Balancing location/{root HTML;   #默认主页目录在nginx安装目录的html子目录 index index.html index.htm index.aspx; #没有索引页时, listing files and subdirectories #proxy_pass http://www.imicrosoft.net;  #跟载均衡服务器的upstream对应 AutoIndex on; #没有索引页时, listing the files and subdirectories #保留用户真实信息 proxy_redirect off; #url不跳转 Proxy_set_header Host $host; 
            Proxy_set_header X-real-ip $remote _addr;
		   Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
           #缓冲区代理缓冲用户端请求的最大字节数, can be understood as first save to the local and then to the user # Client_body_buffer_size 128k;
           # #跟后端服务器连接超时时间 handshake Waiting for Response timeout # proxy_connect_timeout 12;
           # #连接成功后 wait for back-end server response time has actually entered the back-end queue waiting for processing # Proxy_read_timeout 90;
           # #代理请求缓存区 This cache interval will save the user's header information altogether nginx rules processing generally as long as can save the head information can be # Proxy_send_timeout 90;
           # #同上 tell Nginx how much space to save for a single use of the maximum number of buffer proxy_buffer_size 4k;
           # proxy_buffers 4 32k;
           # #如果系统很忙的时候可以申请国内各大的proxy_buffers officially recommended *2 # Proxy_busy_buffers_size 64k; 
           # #proxy Cache the size of temporary files proxy_temp_file_write_size 64k; 
            # Proxy_next_upstream Error timeout Invalid_header http_500 http_503 http_404;
           Proxy_max_temp_file_size 128m;
#启动代理 Proxy_pass http://localhost;           Client_max_body_size 10m;
		#允许客户端请求的最大单个文件字节数} #示例一 #location/{# Proxy_pass http://imicrosoft.net;
        # # Proxy_redirect default;
        # # Proxy_set_header Host $host;
        # Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
        #} #示例二 #location/tileservice {# Proxy_pass http://cluster/MongoTileService/tileService;
        # Proxy_set_header Host $host;
        # Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

        #} #error_page 404/404.html;
        # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html;
        Location =/50x.html {root html; # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 #对 '/xxxxx.
    PHP "Enable load Balancing #location ~ \.php$ {# Proxy_pass http://127.0.0.1;    #} #location/baidu #{#proxy_pass http://www.google.com;
		#proxy_set_header Host $host;
		#proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
        # 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 {# l
    Isten 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;
 #    }
    #}

}
The result is as shown in figure:

IIS site



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.