Windows-based Ngnix base usage

Source: Internet
Author: User
Tags get ip

Objective

Today, the leader of the early morning impulse to tell me, I hope that our group of computers to do Web site server cluster, you make a mess, use Ngnix bar.

June to death, the minister had to die. By the way write an article to make a note.

Brief introduction

Nginx is a high-performance HTTP and reverse proxy server, also a IMAP/POP3/SMTP service. Easy to use, low learning cost, high maintainability. portals.

Welcome to use

After downloading the nginx/windows-1.6.3 version, unzip it. There are two ways of booting

1. Double-click Nginx.exe (nonsense)

2. Execute with cmd (CD F:\nginx-1.6.3 Enter start Nginx Enter)

If successful, in the browser hit http://localhost/, will appear the Welcome page, see

Build a test Site

I built a Web site with a basic MVC framework, deployed it on IIS, and wrote two sentences in the background of index

viewdata["IP"] = system.web.httpcontext.current.request.userhostaddress;//Get IP address
viewdata["url"] = Request.Url.ToString ();//Get URL

Two variables are displayed on the page, mainly to facilitate the verification of the results.

Modifying the Ngnix configuration

Basic are ready, now modify the Ngnix configuration, map to the corresponding site address on it, nginx-1.6.3\conf under the nginx.conf file.

Altogether three modification points:

1. Add the site address you want to map on server {above

Upstream chengong.com {
Server 127.0.0.1:5555;
Server 127.0.0.1:4444;
}

2, in server_name changed to server_name chengong.com;

3. Change location to

Location/{
Proxy_pass http://chengong.com;
Proxy_redirect default;
}

Save, with cmd command ngnix.exe-s reload, multiple refresh http://localhost/.

You will see two alternate addresses displayed alternately. That means it's a success.

Additional directives

Ngnix.exe-s Stop Stop

Start Ngnix.exe Startup

Ngnix.exe-s Reload Restart

End

The overall use is still relatively simple, if you need to ngnix more advanced use can view his configuration document.

This time the main record of their own research process and results, if there are deficiencies and suggestions to trouble everyone in the comments pointed out.

Windows-based Ngnix base usage

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.