`

nginx reverse proxy cofinguration

 
阅读更多
based on our case, we need to handle two different url request:
    example/0.5/xxx ==> 192.168.1.100:8080/xxx
    example/0.7/xxx ==> 192.168.1.101:8080/xxx
Here is the configuration:
引用

root@p1:/etc/nginx/conf.d# cat /etc/nginx/conf.d/default.conf
## Basic reverse proxy server ##
## Apache (vm02) backend for www.example.com ##
upstream developserver  {
      server 192.168.1.100:8080; #Develop Server
}

## Lighttpd (vm01) backend for static.example.com ##
upstream productionserver  {
      server 192.168.1.100:8080; #Production Server
}

## Start www.example.com ##
server {
    listen       10.0.3.138:80; # ip address of proxy server
    server_name  www.example.com;

    access_log  /var/log/nginx/www.example.access.log main;
    error_log  /var/log/nginx/www.example.error.log;
    root   /usr/share/nginx/html;
    index  index.html index.htm;

    ## send request back to apache1 ##
    location /0.5 {
     rewrite /0\.5/(.*) /$1 break;
     proxy_pass  http://developserver;
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
     proxy_redirect off;
     proxy_buffering off;
     proxy_set_header        Host            $host;
     proxy_set_header        X-Real-IP       $remote_addr;
     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
   }
   location /0.7 {
        proxy_pass  http://productionserver;
        rewrite /0\.7/(.*) /$1 break;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header        Host            static.example.com;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}


引用

root@p1:/etc/nginx/conf.d# diff -u  /etc/nginx/nginx.conf.bkp /etc/nginx/nginx.conf
--- /etc/nginx/nginx.conf.bkp 2015-08-28 14:09:19.744354204 +0800
+++ /etc/nginx/nginx.conf 2015-08-28 14:55:35.264441341 +0800
@@ -22,7 +22,9 @@

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
-
+ log_format main '$remote_addr - $remote_user [$time_local] $request '
+ '"$status" $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"';
include /etc/nginx/mime.types;
default_type application/octet-stream;
分享到:
评论

相关推荐

    nginx config reverse proxy for windows.pdf

    反向代理(Reverse Proxy)是一种常用的网络架构模式,通过使用反向代理,可以将客户端的请求转发到内部服务器,提高了网络安全性和负载均衡能力。 在本文中,我们将介绍如何使用 Nginx 配置反向代理,实现 ...

    reverse-proxy:我的Ubuntu服务器上使用的NGINX反向代理

    `nginx-proxy`是一个流行的Docker容器,它可以自动处理容器的网络配置,为每个容器分配一个虚拟主机。要使用`nginx-proxy`,首先需要启动它: ```bash docker run -d --name nginx-proxy \ -v /var/run/docker....

    self-signed-docker-nginx-reverse-proxy

    Run an NGINX reverse proxy with SSL in front of a specified port. positional arguments: CMD 'up' or 'down' flag arguments: -h, --help show this help message and exit -n, --name NAME Docker cont

    Nginx 控制 启动 脚本

    # description: nginx is a HTTP and reverse proxy server # ### BEGIN INIT INFO # Provides: nginx # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default...

    nginx实现请求转发

    nginx 反向代理官方文档: NGINX REVERSE PROXY 当在一台主机上部署了多个不同的web服务器,并且需要能在80端口同时访问这些web服务器时,可以使用 nginx 的反向代理功能: 用 nginx 在80端口监听所有请求,并依据转发...

    nginx-fpm-reverse-proxy

    快速开始docker run \ -ti \ --rm \ -name nginx-fpm-reverse-proxy \ -v ${pwd}:/opt/kimai \ -p 8001:80 \tobybatch/nginx-fpm-reverse-proxy建造没有自定义构建时间: docker build .环境变量PORT=80 Nginx服务器...

    ecs-nginx-proxy:AWS ECS的反向代理。 让您按子域寻址Docker容器

    ecs-nginx-proxy:AWS ECS的反向代理。 让您按子域寻址Docker容器

    containerized_nginx_reverse_proxy:在Docker容器中放置Nginx和应用程序的反向代理演示

    containerized_nginx_reverse_proxy Nginx和应用程序都在Docker容器中的反向代理演示

    nginx安装配置全攻略

    # description: Nginx is an HTTP server and a reverse proxy server. # processname: nginx # config: /etc/nginx/nginx.conf # pidfile: /var/run/nginx/nginx.pid # lockfile: /var/lock/subsys/nginx # ...

    EwoMail开源邮件服务器软件

    EwoMail是基于Linux的开源邮件服务器软件,集成了众多优秀稳定的组件,是一个快速部署、简单高效、多语言、安全稳定的邮件解决方案。帮助你提升运维效率,降低 IT 成本,兼容主流的邮件客户端,同时支持电脑和手机...

    nginx 官方cookbook

    This book is about NGINX the web server, reverse proxy, load balancer, and HTTP cache. Part I will focus mostly on the load-balancing aspect and the advanced features around load balancing, as well ...

    利用Nginx反向代理解决跨域问题详解

    问题 在之前的分享的跨域资源共享的文章中,有提到要注意跨域时,如果要发送Cookie,Access-Control-Allow-Origin就不能设为*,必须指定明确的、与请求网页...反向代理(Reverse Proxy)方式是指以代理服务器来接受In

    odoo-nginx-reverse-proxy:具有docker的Odoo实例。 使用工作人员和充当反向代理的nginx容器定制的Odoo

    重要的每当您第一次运行时,都必须重新加载nginx配置文件。 可以通过键入以下命令来... Nginx公开了80个(默认)和8069个端口(在dockerfile文件中指定) 在docker-compose文件中,odoo_proxy(nginx)发布8069端口。

    centOS8安装nginx及nginx配置

    Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local...

    nginx将进程注册为Windows服务

    <description>Nginx HTTP and reverse proxy server. <executable>C:\path\to\nginx.exe <arguments>-g "daemon off;" ``` 这里`<id>`是服务的唯一标识,`<name>`和`<description>`是显示的服务名和描述,`...

    详解Nginx 利用代理转发请求示例

    我们米扑科技的业务遍布全球,有时国外的客户无法访问我们搭建在国内的服务,这就要求我们...nginx 反向代理官方文档: NGINX REVERSE PROXY 当在一台主机上部署了多个不同的web服务器,并且需要能在80和443端口同时访问

    nginx开发指南

    2. **Reverse Proxy Cache**:作为反向代理服务器,Nginx 可以缓存来自上游服务器的数据。这在内容经常变化但更新频率较低的应用程序中特别有用。 - 配置示例: ```nginx http { ... proxy_cache_path /var/...

    docker-nginx-reverse-proxy-with-tests:一个简单的项目,展示了如何在 docker 中使用 wiremock 测试 nginx

    docker-nginx-reverse-proxy-with-tests 展示如何使用 WireMock 为 dockerized NGINX 实例编写自动化测试的简单项目。 有关更多信息,请参阅我的 环境设置 要在本地运行运行... ./buildRunAndTest.sh ##图表

    nginx-reverse-proxy-ispconfig:使用Nginx作为反向代理为Apache生成Nginx conf

    Nginx与Apache反向代理配置生成器 该脚本根据您传递给它的参数生成Nginx vhost配置。 .vhost文件与使用Nginx作为Apache的反向代理兼容。 随时根据您的需求进行调整。 它还会在/ var / log / nginx / vhosts / ...

    nginx-docker-reverse-proxy:Nginx作为Docker容器的反向代理

    Nginx作为Docker容器的反向代理 关于 该存储库是如何使用NGINX Docker容器作为反向代理的示例,该代理是在其他Dockers容器中运行的另一个应用程序的。 什么是反向代理 来自NGINX页面的定义: 代理服务器是介于中间...

Global site tag (gtag.js) - Google Analytics