Nginx181 configure reverse proxy

Source: Internet
Author: User
: This article describes how to configure the reverse proxy for nginx181. For more information about PHP tutorials, see.
The previous article introduced how to install nginx1.8.1 and how to use nginx1.8.1 to reverse proxy tomcat.

My environment:

The local machine is the Windows system ip address: 192.168.1.131 tomcat Port: 192.168.1.131: 8085 virtual machine is Ubuntu14.04 system ip address: 192.168.1.150 nginx Port: 80

Reverse proxy result:

Enter 192.168.1.150 to view the 192.168.1.131: 8085 page.

1: Create a new proxy. conf with the same path as nginx. conf.

sudo vim /usr/local/nginx/conf/proxy.conf

2: write the following content into proxy. conf

#! Nginx (-) # proxy. confproxy_redirect off; proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; # obtain the Real ip address # proxy_set_header X-Forwarded-For $ timeout; # obtain the proxy's Real quota 10 m; limit 128 k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4 k; proxy_buffers 4 32 k; limit 64 k; proxy_temp_file_write_size 64 k;

3: write the following content into nginx. conf

# User name and user group for running nginx # user www; # Number of processes started worker_processes 8; # global error log and PID file error_log/usr/local/nginx/logs/nginx_error.log crit; pid/usr/local/nginx. pid; # Specifies the value for maximum file descriptors that can be opened by thisprocess. worker_rlimit_nofile 65535; # working mode and maximum number of connections events {use epoll; worker_connections 65535;} # set the http server, using its reverse proxy function, server load balancer supports http {# set the mime type include mime. types; default_type application/octet-stream; include/usr/local/nginx/conf/proxy. conf; # charset gb2312; # set request buffer limit 128; limit 32 k; limit 4 32 k; # client_max_body_size 8 m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; # limit_zone crawler $ binary_remote_addr 10 m; ### prohibit access to site server {server_name _; return 404;} server {listen 80; server_name localhost 127.0.0.1 192.168.1.150 through ip addresses; # use these three domain names to access rewrite ^/ http://192.168.1.131:8085 ; # Limit_conn crawler 20; location ~ (\. Jsp) | (\. do) | (\. js) | (\. css) | \. (gif | jpg | jpeg | png | bmp | swf) $ # All actions are processed by tomcat {proxy_pass http://192.168.1.131:8085 ; # Switch to tomcat to handle proxy_redirect default ;}}}

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces nginx181 configuration of reverse proxy, including content, hope to be helpful to friends interested in PHP tutorials.

    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.