Using the nginx-Load balancer configuration

Source: Internet
Author: User

Pre-built environment required:

1 . openssl-fips-2.0.5.tar.gz

2.pcre-8.32.tar.gz

3.zlib-1.2.7.tar.gz

4 . nginx-1.2.6.tar.gz


1) root user mkdir directory/usr/local/nginx/

2) Place these 4 packages in this directory and TAR-ZXVF *.tar.gz unzip

3) Install openssl-fips-2.0.5,

3.1) cd/usr/local/nginx/openssl-fips-2.0.5/

3.2)./config

3.3) Make

3.4) make Install

4) Install pcre-8.32 and zlib-1.2.7 with * instead

4.1) cd/usr/local/nginx/*/

4.2)./configure

4.3) make

4.4) Make Install

5) Install nginx-1.2.6

5.1)cd/usr/local/nginx/nginx-1.2.6/

5.2)

./configure--with-pcre=. /pcre-8.32--with-zlib=. /zlib-1.2.7--with-openssl=. /openssl-fips-2.0.5

5.3) Make

5.4) make Install

6) Check if the installation is successful


This is a case in which it is said to be right.

Then look at the/usr/local/nginx/conf/nginx.conf, the main want to see the port number,

in /usr/local/nginx/conf/path has a nginx.conf.default, in fact, I used this, "original ecology" This file is as follows,

#user   nobody;worker_processes  1; #error_log   logs/error.log; #error_log    logs/error.log  notice; #error_log   logs/error.log  info; #pid          logs/nginx.pid;events {    worker_connections   1024;} http {    include       mime.types;     default_type  application/octet-stream;     #log_format    main   ' $remote _addr -  $remote _user [$time _local]  "$request"   "     #                    ' $status   $body _bytes_sent  "$http _referer   '     #                    ' "$http _user_ Agent " "$http _x_forwarded_for "';     #access_log   logs/access.log  main;     sendfile        on;     #tcp_ nopush     on;     #keepalive_timeout   0;     keepalive_timeout  65;     #gzip   on;     server {        listen        80;        server_name  localhost;          #charset  koi8-r;         #access_log   logs/host.access.log  main;        location  / {            root    Html;            index  index.html index.htm;         }         #error_page   404               /404.html;         # redirect server error pages to the  static page /50x.html        #         error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }        # proxy the php scripts to  apache listening on 127.0.0.1:80        #          #location  ~ \.php$ {        #     proxy_pass   http://127.0.0.1;        #}         # pass the php scripts to fastcgi  server listening on 127.0.0.1:9000        #          #location  ~ \.php$ {         #    root            html;        #    fastcgi_pass    127.0.0.1:9000;        #    fastcgi_index   index.php;        #    fastcgi_param  script_filename   /scripts$fastcgi_script_name;        #     include        fastcgi_params;         #}        # deny access to .htaccess  files, if apache ' s document root        #  concurs with nginx ' s one        #          #location  ~ /\.ht {         #    deny  all;        #}     }    # another virtual host using mix  of ip-, name-, and port-based configuration    #     #server  {     #    listen       8000;     #    listen       somename:8080;     #    server_name  somename  alias   another.alias;    #    location / {    #         root   html;    #         index  index.html index.htm;    #     }    #}    # HTTPS server     #     #server  {    #     listen       443;    #    server_name  localhost;     #    ssl                   on;    #    ssl_certificate       cert.pem;    #    ssl_certificate_ key  cert.key;    #    ssl_session_timeout  5m;     #    ssl_protocols  SSLv2 SSLv3 TLSv1;     #    ssl_ciphers  high:!anull:! md5;    #    ssl_prefer_server_ciphers   on;     #    location / {    #         root   html;    #        index  index.html index.htm;     #    }    #}}

As you can see, the port number listen 80, so I tested access to http://210.10.5.189:80/,5.189 is this deployed Nginx service Linux Red Hat 6

So the deployment is correct.

In fact, the page here is the directory/usr/local/nginx/html below, so the default state static page is in this directory

<! Doctype html>


7) Modify the configuration "static and dynamic separation" to achieve load balancing

Referring to the PHP reverse proxy configuration, I configured the Java reverse proxy, meaning that the. do and. JSP requires a reverse proxy, the address is 5.102:8,080,

After modifying the configuration, you need to first stop the service and restart the service.

Stop service:/usr/local/nginx/sbin/nginx-s stop

From service:/usr/local/nginx/sbin/nginx

Test as follows,

If 5.102 of the service is not turned on (5.102 here I use the TOMCAT6, also very common a JSP login page), then the reverse proxy access will result in a time-out link error.



Using the nginx-Load balancer configuration

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.