Nginx matching ip

WBOY
Release: 2016-07-29 09:16:11
Original
1650 people have browsed it

Nginx matching ip

Define reverse proxy

<code>upstream portal<span>.hongxue</span><span>.com</span> {
server <span>192.168</span><span>.0</span><span>.216</span>:<span>100</span> weight=<span>1</span><span>;</span>
}

upstream mobile<span>.hongxue</span><span>.com</span> {
server <span>192.168</span><span>.0</span><span>.216</span>:<span>200</span> weight=<span>1</span><span>;</span>
}

upstream console<span>.hongxue</span><span>.com</span> {
server <span>192.168</span><span>.0</span><span>.216</span>:<span>300</span> weight=<span>1</span><span>;</span>
}</code>
Copy after login

Define Server{} configuration

<code>server {
listen <span>80</span>;
server_name www.hongxue.com;
charset utf8;

location / {
<span>if</span> ( <span>$remote_addr</span> = <span>"10.1.2.6"</span> )
    {
    proxy_pass http:<span>//console.hongxue.com;</span><span>break</span>;
    }
<span>if</span> ( <span>$remote_addr</span> = <span>"10.1.2.5"</span> )
    {
    proxy_pass http:<span>//portal.hongxue.com;</span><span>break</span>;
    }
<span>if</span> ( <span>$remote_addr</span> = <span>"10.1.2.7"</span> )
    {
    proxy_pass http:<span>//mobile.hongxue.com;</span><span>break</span>;
}
    proxy_pass http:<span>//192.168.0.223/;</span>
}
}</code>
Copy after login

Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.

The above introduces Nginx matching IP, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!