WINDOWS 2008Server Configuring Nginx Reverse proxy Server

Source: Internet
Author: User
Tags nginx server nginx reverse proxy

This case is useful and feasible.

0, first in the domain name official network to configure the IP address of the domain name, and then on their own routers to map the 80 port to the IP address to install the Nginx server.

1. Download the nginx1.6.2 version of Windows from the official web side. Access Address http://nginx.org/en/download.html

2. Unzip to the C packing directory below

3, copy C:\nginx\conf\nginx.conf, save as a copy

4, edit nginx.conf, the content is as follows

#工作进程数, the recommended set is the total number of cores for the CPU

Worker_processes 2;

#全局错误日志定义类型, log levels from low to high are:

#debug | info | Notice | Warn | Error | Crit

Error_log Logs/error.log Info;

#记录主进程ID的文件

Pid/nginx/nginx.pid;

#一个进程能打开的文件描述符最大值, theoretically this value is divided by the number of files that can be opened at most.

#但是由于nginx负载并不是完全均衡的, so this value is best equal to the maximum number of files that can be opened.

#LINUX系统可以执行 Sysctl-a | grep Fs.file can see the Linux file descriptor.

Worker_rlimit_nofile 65535;

#连接数上限, the maximum number of connections allowed for a single process

Events {

Worker_connections 65535;

}

#设定http服务器, using its reverse proxy function to provide load balancing support

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 records which users, which pages, and the user's browser, IP, and other access information

access_log Logs/access.log main;

#服务器名字的hash表大小

server_names_hash_bucket_size;

#客户端请求头缓冲大小.

#nginx默认会用client_header_buffer_size这个buffer来读取header值,

#如果header过大, it will be read using Large_client_header_buffers.

#如果设置过小HTTP头/cookie 400 errors in the conference. Nginx Bad Request

HTTP 414 error (URI Too Long) will be reported #如果超过buffer

#nginx接受最长的HTTP头部大小必须比其中一个buffer大

#否则就会报400的HTTP错误 (Bad Request)

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

#客户端请求体的大小

client_body_buffer_size 8m;

#隐藏ngnix版本号

server_tokens off;

#忽略不合法的请求头

ignore_invalid_headers on;

#指定启用除第一条error_page指令以外其他的error_page.

recursive_error_pages on;

#让 Nginx does not use the first domain name in the server_name setting when handling its own internal redirection

server_name_in_redirect off;

#开启文件传输, the general application should be set to on; If you have a downloaded app, you can set it off to balance network I/O and disk I/O to reduce system load

sendfile on;

#告诉nginx在一个数据包里发送所有头文件 instead of sending one after another.

Tcp_nopush on;

#告诉nginx不要缓存数据, but a section of the send-when you need to send data in a timely manner, you should set this property to the application,

#这样发送一小块数据信息时就不能立即得到返回值.

tcp_nodelay on;

#长连接超时时间, Unit is seconds

keepalive_timeout;

#gzip模块设置, using gzip compression can reduce site bandwidth consumption while increasing access speed.

gzip on; #开启gzip

Gzip_min_length 1k; #最小压缩大小

gzip_buffers 4 16k; #压缩缓冲区

Gzip_http_version 1.0; #压缩版本

Gzip_comp_level 2; #压缩等级

gzip_types text/plain application/x-javascript text/css application/xml; #压缩类型

#upstream作负载均衡, where you configure the server address and port number that you want to poll, max_fails the number of times to allow the request to fail, which defaults to 1.

#weight为轮询权重, depending on the weight allocation can be used to balance the server's access rate.

#指定要域名对应的WEB项目访问地址

Upstream hostname {

Server 192.168.33.129:18080 max_fails=0 weight=1;

}

#主机配置

server {

#监听端口

Listen;

#自己指定要跳转的域名

server_name youjie.co;

#字符集

CharSet Utf-8;

#单独的access_log文件

access_log Logs/192.168.33.129.access.log main;

#反向代理配置,

#将所有请求为http: All//hostname requests are forwarded to the target server defined in upstream.

Location /{

#此处配置的域名必须与upstream的域名一致 to forward.

Proxy_pass/HTTP hostname;

proxy_set_header x-real-ip $remote _addr;

 }

#启用nginx Status Monitor Page

Location/nginxstatus {

stub_status on;

Access_log on;

}

#错误页面

Error_page 502 503 504/50x.html;

Location =/50x.html {

root html;

 }

  }

Upstream hostname1 {

Server 192.168.33.129:28080 max_fails=0 weight=1;

}

server {

#监听端口

Listen;

#自己指定要访问的域名

server_name u-pai.cn;

#字符集

CharSet Utf-8;

# separate access_log files

Access_log Logs/192.168.33.129.access.log Main;

#反向代理配置,

#将所有请求为http: All//HOSTNAME1 requests are forwarded to the target server defined in upstream.

Location /{

#此处配置的域名必须与upstream的域名一致 to forward.

Proxy_pass http://hostname1;

Proxy_set_header X-real-ip $remote _addr;

}

#启用nginx Status Monitor Page

Location/nginxstatus {

Stub_status on;

Access_log on;

}

#错误页面

Error_page 502 503 504/50x.html;

Location =/50x.html {

root HTML;

}

}

}

To this configuration complete

5. Start Nginx

Start Menu--run-->cmd-->

CD c:\nginx\

Nginx

Start complete

6. Visit

You can now enter u-pai,youjie.co access to different websites in the browser.

Article reference: http://blog.csdn.net/zxcvqwer19900720/article/details/24991427

http://blog.csdn.net/zhanglujie2008/article/details/24445037

http://blog.csdn.net/Poechant/article/details/7256184

WINDOWS 2008Server Configuring Nginx Reverse proxy Server

Related Article

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.