GithubHelp home page GithubHelp logo

pombredanne / nginx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from izenecloud/nginx

0.0 1.0 0.0 3.8 MB

Http reverse proxy for sf1r based on nginx

License: Apache License 2.0

CMake 0.10% C 66.34% Perl 26.42% Shell 0.05% C++ 1.16% Perl 6 4.60% HTML 0.04% Nginx 0.04% Python 0.02% Groff 0.08% XS 0.30% Objective-C 0.02% Assembly 0.02% Lua 0.82%

nginx's Introduction

Http reverse proxy for sf1r based on nginx

Features

  • Zookeeper Aware: This reverse proxy requires Zookeeper to get aware of SF1R's node topology. This is the first nginx project to be able to connect with Zookeeper. We delivered such feature through nginx module. Since this project was started in early 2012, while currently, if similar features are required, we might choose to recommend providing glue codes based on nginx lua module.

###Requirements The sf1r-module uses the libsf1r in the izenelib project.

The following libraries are also needed:

###Installation

Check out the Nginx source code:

git clone https://github.com/izenecloud/nginx.git

Create the build directory:

cd nginx
mkdir build && cd build

Configure:

cmake ..

It is possible to enable the debug output using the following options:

  • -DWITH_DEBUG=1 enables the module debug output (disabled by default)
  • -DWITH_NGINX_DEBUG=1 enable the Nginx debug output (disabled by default)
  • -DJOBS=4 set the number of jobs, passed to the make -j option (default set to 2)

The installation prefix can also be specified with the -DCMAKE_INSTALL_PREFIX=/path/to/[cmake](https://github.com/izenecloud/cmake) option.

Build and install:

make install

Documents

The technical report could be accessed here and here.

###Configuration

Nginx can be configured by editing the file conf/nginx.conf.

Single SF1

Here is a sample configuration snippet, add it to the server section:

underscores_in_headers on;
location /sf1r/ {
    rewrite ^/sf1r(/.*)$ $1 break;
    sf1r_addr host1:port1;
    sf1r_poolSize 5;                                # default: 5
    sf1r_poolResize on;                             # default: off
    sf1r_poolMaxSize 10;                            # default: 25
    # allow use from Javascript
    more_set_headers 'Access-Control-Allow-Origin: *';
    more_set_headers 'Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS';
    more_set_headers 'Access-Control-Allow-Headers: CONTENT-TYPE';
    more_set_headers 'Access-Control-Max-Age: 1728000';
    more_set_headers 'Access-Control-Allow-Credentials: false';
}
Distributed SF1

Here is a sample configuration snippet, add it to the server section:

underscores_in_headers on;
location /sf1r/ {
    rewrite ^/sf1r(/.*)$ $1 break;
    sf1r_addr zookeeper1:port,zookeeper2:port distributed; 
    sf1r_poolSize 5;                                # default: 5
    sf1r_poolResize on;                             # default: off
    sf1r_poolMaxSize 10;                            # default: 25
    sf1r_zkTimeout 1000;                            # default: 2000
    sf1r_broadcast ^test/\w+$;                      # broadcast /test/* requests
    sf1r_broadcast ^recommend/visit_item$;          # broadcast visit_item requests
    # allow use from Javascript
    more_set_headers 'Access-Control-Allow-Origin: *';
    more_set_headers 'Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS';
    more_set_headers 'Access-Control-Allow-Headers: CONTENT-TYPE';
    more_set_headers 'Access-Control-Max-Age: 1728000';
    more_set_headers 'Access-Control-Allow-Credentials: false';

For more details about Nginx configuration, please refer to the Nginx Wiki.

The following directive are available:

sf1r_addr host1:port1[,host2:port2] [single|distributed] : Define the upstream SF1. Using the single flag (default) only one SF1 address in the format host:port is required. When using the distributed flag it is possible to define more hosts, each of them creesponding to a ZooKeeper server.

sf1r_poolSize size : Connection pool size (default: 5).

sf1r_poolResize [on|off] : Connection pool automatic resize (default: off).

sf1r_poolMaxSize size : Connection pool maximum size when resize is enabled (default: 25).

sf1r_timeout seconds : Request timeout (default: 60).

sf1r_zkTimeout millis : ZooKeeper timeout, available only when setting the distributed flag (default: 2000).

sf1r_broadcast regex : Broadcast request matching the URI regex, available only when setting the distributed flag.

###Run

Nginx can be started with the command:

sbin/nginx

The logs directory will contain three files:

  1. access.log the requested URI
  2. error.log Nginx standard error
  3. nginx.pid the master process' PID

More information on how to use Nginx command line is available at this page.

##Higher performance

By default, nginx, together with sf1r-module could provide acceptable concurrency. While if higher concurrency load is required, Fast-cgi is a better choice. You could access it from directory of SF1R.

License

The SF1R project is published under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

nginx's People

Contributors

dapicester avatar skyyan avatar yingfeng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.