Configure reverse proxy server with Nginx

  Let’s talk about how to use Nginx’s reverse proxy function to make a reverse proxy server. 1. Installation steps: “ “ (System requirements: Linux 2.6+ kernel, the Linux operating system in this article is RedHat AS4 as an example) 1. Obtain relevant source programs wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.01.tar.gz wget http://sysoev.ru/nginx/nginx-0.8.36.tar.gz 2. Create related directories and users /usr/sbin/groupadd apache /usr/sbin/useradd -g apache apache /usr/sbin/usermod -s /sbin/nologin apache chage -I -1 -M 99999 apache mkdir -p /data/mp3 chmod +w /data/mp3 chown -R apache:apache /data/mp3   3. Install the pcre library required by Nginx tar zxvf pcre-8.01.tar.gz cd pcre-8.01/ ./configure make && make install cd ../ 4. Install Nginx tar zxvf nginx-0.8.36.tar.gz cd nginx-0.8.36/ ./configure –user=apache –group=apache –prefix=/usr/local/nginx –with-http_stub_status_module make && make install cd ../ 5. Create Nginx configuration file rm -f /usr/local/nginx/conf/nginx.conf vi /usr/local/nginx/conf/nginx.conf Enter the following: “ “ user apache apache; worker_processes 8; “ “ error_log /dev/null crit; pid logs/nginx.pid; “ “ events { use epoll; worker_connections 512000; } “ “ 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 /var/log/nginx_mp3.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 650; server { listen 80; server_name xxx.xxx.xxx; #Front-end domain name or IP…

Performance efficiency test comparison between Nginx and Apache

Performance efficiency test comparison between Nginx and Apache

It is said that nginx performs better than apache in a high-stress environment, so I downloaded one to toss about it. Download and compile and install, my compilation process is a bit special: 1. Remove the debugging information, modify the $nginx_setup_path/auto/cc/gcc file, and set CFLAGS=”$CFLAGS -g” This line is commented out. 2. Since only the performance of the WEB server is tested, FastCGI is not installed. 1 2 3 4 5 6 7 ./configure\ –prefix=/opt/nginx\ –user=www\ –group=www\ –with-http_stub_status_module \ –with-http_ssl_module\ –without-http_fastcgi_module After the installation is complete, copy a bunch of static HTML pages in the production environment to the nginx server, my nginx.conf The configuration is as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 twenty one twenty two twenty three twenty four 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 worker_processes 8; worker_rlimit_nofile 102400; events { use epoll; worker_connections 204800; } http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; charset GBK; keepalive_timeout 60; server_names_hash_bucket_size 128; client_header_buffer_size 2k; large_client_header_buffers 4 4k; client_max_body_size 8m; open_file_cache max=102400 inactive=20s; server {                   80; location / {…

The installation and configuration process of Nginx+Keepalvied+tomcat cluster

Paste the nginx.conf configuration file here, without any explanation, it is convenient to paste directly with X-shell, very user-friendly:) Two nginx loads The files of the equalizer are the same. After the configuration is completed, start them with /usr/local/nginx/sbin/nginx respectively. user nobody nobody; worker_processes 1; pid /usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-avascript text/css application/xml; gzip_vary on; upstream backend { server 192.168.1.102:8080; server 192.168.1.103:8080; server 192.168.1.105:8080; } server { listen 80; server_name location / { root /var/www; index index.jsp index.htm index.html; proxy_redirect 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; proxy_pass } #location /nginx { #access_log on; #auth_basic “NginxStatus”; #auth_basic_user_file /usr/local/nginx/htpasswd; #} log_format access ‘$remote_addr – $remote_user [$time_local] “$request”‘ ‘$status $body_bytes_sent “$http_referer”‘ ‘”$http_user_agent” $http_x_forwarded_for’; access_log /var/log/access.log access; } } ③Install and configure keepalived on the two Nginx machines to make mutual backup between the two machines. #wget #tar zxvf keepalived-1.1.15.tar.gz #cd keepalived-1.1.15 #./configure…

Install and use Nginx under Windows2003 system

nginx can really exert its good load capacity under linux. We set up a good environment under windows to test, develop and use. It is strongly recommended to develop under linux. —- download nginx Visit www.nginx.org, download the latest development version: 1.1.5 (it seems that nginx will also show signs of developing towards version emperor) File name: nginx-1.1.5.zip Create an nginx directory on the hard disk and unzip it. There is only one nginx.exe file in the directory, and the total size does not exceed 2.15M, which is really slim. If you just want to do html parsing, just run nginx.exe directly. The default web directory is nginx\html, and we generally need to configure it to support php, haha. nginx+php+FastCGI Here using the latest version of php 5.3.8 (as of October 14, 2011) Download php, visit www.php.net, select the windows version of php to download, download non-thread-safe or thread-safe, here pay attention: What is Non Thread Safe? Non Thread Safe is non-thread safe; What is Thread Safe? Non Thread Safe is thread safe; The official does not recommend that you apply Non Thread Safe to the production environment, so we choose the Thread Safe version of PHP to use We…

The installation and configuration process of Nginx+PHP+MySQL+Tomcat server environment

The installation steps are as follows: 1. Nginx 1.1 Add source and install 1.1.1 sudo add-apt-repository ppa:nginx/stable 1.1.2 sudo apt-get update 1.1.3 sudo apt-get install nginx 1.2 Testing 1.2.1 Start nginx: sudo /etc/init.d/nginx start 1.2.2 Access: http://localhost appears “Welcome to nginx!”, the installation is successful. 1.2.3 Close nginx: sudo /etc/init.d/nginx stop 2.PHP 2.1 Installation 2.1.1 sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql php5-fpm: One of the ways to cooperate with nginx, the other is: spawn-fcgi; php5-mysql: access mysql; 2.2 Modify nginx configuration 2.2.1 sudo vim /etc/nginx/sites-available/default 2.2.2 Change the line of index to: “index index.html index.htm index.php;” Uncomment the following to support php scripts: location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } 2.3 Testing 2.3.1 Create a new directory: sudo mkdir /var/www/ 2.3.2 Modify nginx directory: sudo vim /etc/nginx/sites-available/default Change the root line to “root /var/www;” 2.3.3 Create a new test file: sudo vim /var/www/test.php Input: “” 2.3.4 Start nginx: sudo /etc/init.d/nginx start 2.3.5 Access: http://localhost/test.php The php details appear and the configuration is successful. 2.3.6 Close nginx: sudo /etc/init.d/nginx stop 3. MySQL 3.1 Installation 3.1.1 sudo apt-get install mysql-server During the installation process, you will be asked to set a root password. 3.2 Testing 3.2.1…

Use Nginx to reverse proxy weblogic

I have been using apache as the front end of weblogic before, but due to the excellent performance of nginx for static content, I have to switch to nginx. Not here Then write the installation of weblogic. install nginx nginx needs pcre for support, and the general system comes with it. Of course, you can download a higher version of the source package and install it yourself. It is recommended that you use a higher version of pcre. In this way, there will be better support when using regular expressions. First go to http://wiki.nginx.org//NginxChs to download nginx, I used 0.7 # tar zxvf nginx-0.7.59.tar.gz # cd nginx-0.7.59 # ./configure –with-http_stub_status_module ?prefix=/opt/nginx # make # make install –with-http_stub_status_module Add nginx monitoring module to monitor Nginx current state of . Let’s configure nginx Configuration file, nginx.conf under /opt/nginx/conf, to save trouble, directly copy my configuration file: #user nobody; worker_processes 10; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { use epoll; //The way nginx handles connections, epoll – Efficient method for Linux kernel version 2.6 and later systems. worker_connections 51200; } 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”‘…

UbuntuServer10.10 installation and configuration RVMRubyRails3passengerNgi

1. Update the system as a non-root user sudo apt-get update sudo apt-get upgrade 2. Set the host name, if the system is installed graphically, this step can be ignored sudo hostname your-hostname Add 127.0.0.1 your-hostname: sudo vim /etc/hosts Write your-hostname in: sudo vim /etc/hostname Verify that hostname is set: hostname 3. Install git &curl as non-root The new ubuntu system needs to install these packages; sudo apt-get install curl git 4. Install RVM $ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) add below to your .bashrc. [[ -s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm” Once you edit your bashrc file execute the following to load rvm without logging out and back in Delete all returns in ~/.bashrc, [ -z “$PS1” ] && return Change to [ -z “$PS1” ] run: source ~/.rvm/scripts/rvm Just to be safe check wether rvm is a function, which is what it should be. 5. Install ruby ​​1.9.2 sudo aptitude “bash functions”>install “bash plain”>build-essential bison openssl libreadline5 libreadline5-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev rvm “bash functions”> install “bash plain”>1.9.2 rvm use 1.9.2 –default 6. Install rails3 gem install rails 7. Install passenger and nginx gem install passenger rvmsudo passenger-install-nginx-module This step requires…

Use Nginx+memcached+tomcat to configure load balancing cluster and session sharing

Use Nginx+memcached+tomcat to configure load balancing cluster and session sharing

Configuration Environment: under windows xp jdk1.7.0_10 nginx-1.2.6 (download attached) memcached-1.2.6-win32-bin.zip (download attached)  tomcat7.0.12 *(Note: nginxLoad balancing will not have a big problem, but when configuring session sharing with memcached, the version of tomcat may become the key to success or failure, The tomcat7.0.34 used at the beginning always throws an exception, the reason should be that there is no jar package matching the latest tomcat’s memcached) 1. First, use nginx to build a load balancing environment for three tomcat servers. For how to start three tomcats on one machine, please refer to “Start three tomcats on one machine” The ports of my tomcat are 8081, 8082, 8083 Unzip the downloaded nginx compressed package, my path is D:\MyServer; In D:\MyServer\nginx-1.2.6\conf Next, find nginx.conf, which is the request distribution configuration file for nginx. Open nginx.conf and make the following modifications: (1) in http {…} – server{…} – location / Add a line to {…}: “proxy_pass http://127.0.0.1;” After modification, it is as follows: location / { root html; Index index.html index.htm; Proxy_pass http://127.0.0.1; } (2) Add the following code to http {…}: #Set load balancing server list upstream 127.0.0.1 { The #weigth parameter represents the weight, the higher the weight, the greater the…

Install and integrate Nginx and tomcat in Linux system

System environment centos 5.5 64bit kernel 2.6 1. Before installing nginx, you must install the required dependent packages (1) Install a series of gcc things, and the general server has already installed the installation process: Yum Cy install gcc gcc Cc++ autoconf automake (2) Install support for third-party libraries of nginx Installation command: yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel 2. Go to the official website of nginx (www.nginx.net) to download the nginx version (I installed nginx0.7.67) Installation command: tar: zcvf nginx.0.7.67.tar.gz Cd nginx.0.7.67 ./configure Make Sudo make install 3. The installation is completed above. There is nginx installed under /usr/local/ by default. Start under sbin Start command: ./nginx 4. I use the integration of nginx+tomcat (1) Nginx integration tomcat process 1 Submit a paragraph in nginx.conf upstream tomcat_server{ server 192.168.12.205:8080; –ip and port } server { listen 80; server_name 192.168.12.205; #charset koi8-r; #access_log logs/host.access.log main; access_log logs/205.log combined; –write your log files location / { # root html; index index.html index.htm index.jsp index.do; root /usr/server/sites/videopro; –dynamic project path proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; index index.do index.jspa index.htm index.jsp; proxy_pass http://tomcat_server; — this is the name of your upstream } 5. Restart nginx to…

Windows system installation and configuration Nginx+PHP5.3 server environment

1. Download nginx-0750-win32-setup.exe And php5.3.4 (must be php-5.3.4-Win32-VC6-x86, not php-5.3.4-nts-Win32-VC6-x86, this version does not have php5ts.dll) 2. Install nginx (installed to C:\nginx by default), install php to C:\php, and then configure nginx: #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 {                   80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; Location / { root html; index index.html index.htm index.php; } #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 /nginx/html$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache’s document root      # concurs with nginx’s one # #location ~ /\.ht {…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索