Maison > développement back-end > tutoriel php > 基于HTTP的反向代理

基于HTTP的反向代理

WBOY
Libérer: 2016-07-30 13:29:40
original
1387 Les gens l'ont consulté

一、安装步骤:

<code>cd /app
wget http://nginx<span>.org</span>/download/nginx-<span>1.6</span><span>.3</span><span>.tar</span><span>.gz</span>
unzip nginx-<span>1.6</span><span>.3</span><span>.tar</span><span>.gz</span>
cd /app/nginx-<span>1.6</span><span>.3</span>
./configure
make
make install</code>
Copier après la connexion

二、nginx.conf文件中配置负载均衡

<code><span>worker_processes</span><span>1</span>;
<span>events</span> {
    <span>worker_connections</span><span>1024</span>;
}

<span>http</span> {
    <span>include</span>       mime.types;
    <span>default_type</span>  application/octet-stream;

    <span>log_format</span>  main  <span>'<span>$remote_addr</span> - <span>$remote_user</span> [<span>$time_local</span>] "<span>$request</span>" '</span><span>'<span>$status</span><span>$body_bytes_sent</span> "<span>$http_referer</span>" '</span><span>'"<span>$http_user_agent</span>" "<span>$http_x_forwarded_for</span>"'</span>;

    <span>upstream</span> baidu {
        <span>server</span><span>10.100.138.1:8080</span>;
        <span>server</span><span>10.100.138.2:8080</span>;
    }

    <span>server</span> {
        <span>listen</span><span>80</span>;
        <span>server_name</span> www.baidu.com;
        <span>access_log</span> /app/nginx/logs/baidu.log main;

        <span>location</span> /  {
            <span>proxy_set_header</span>   Host             <span>$host</span>;
            <span>proxy_set_header</span>   X-Real-IP        <span>$remote_addr</span>;
            <span>proxy_set_header</span>   X-Forwarded-For  <span>$proxy_add_x_forwarded_for</span>;
            <span>proxy_pass</span><span>http://baidu</span>;
        }
    }

}
</code>
Copier après la connexion

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了基于HTTP的反向代理,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal