CENTOS7 Nginx front-end Apache backend and multi-site simple configuration

Source: Internet
Author: User

cd /usr/local/srcwget http://nginx.org/download/nginx-1.7.6.tar.gztar –xvf  Nginx-1.7.6.tar.gzcd nginx-1.7.6./configure --prefix=/usr/local/nginx --with-http_stub_status_ module --with-http_ssl_module --with-pcremake make installvi /usr/local/nginx/conf/ nginx.conf 1user  nobody nobody; 2# START Process  3worker_processes  5; 4# Global error log and PID file  5error_log  logs/error.log notice; 6pid         logs/nginx.pid; 7# working mode and maximum number of connections  8events { 9# working modes are: Select (Standard mode), poll (Standard mode), Kqueue (efficient mode, for freebsd 4.1+, openbsd 2.9+, netbsd 2.0 and macos x), 10# Epoll (efficient mode, in this case.) For linux 2.6+,suse 8.2,),     #/dev/poll (High efficiency mode, suitable for solaris 7 11/99+,  hp/ux 11.22+  (Eventport), irix 6.5.15+  and  tru64 unix 5.1a+) 11use  Epoll;12worker_connections      1024;13}14# sets up an HTTP server and uses its reverse proxy feature to provide load balancing support 15http {16# Set MIME type 17include      conf/mime.types;18default_type  application/ octet-stream;19# Setting the log format 20log_format main         ' $remote _addr  -  $remote _user [$time _local]  ' 21                         ' $request '   $status   $bytes _sent  ' 22                         "$http _referer"   "$http _user_agent"   ' 23                          ' "$gzip _ratio" ';2425log_format download     ' $remote _addr  -  $remote _user [$time _local]  '                          ' $request   $status   $bytes _sent  '                           ' $http _referer   $http _user_agent   '                          ' $http _range   $sent _http_content_range "'; 26# set request buffering 27client_header_buffer_size    10k;28large_client_header_ buffers  4 4k;2930# Open the Gzip module to require the installation of gzip  when running./config to specify 31gzip on;32gzip_min_length   1100;33gzip_buffers    4 8k;34gzip_types       text/plain;35output_buffers  1 32k;36postpone_output  1460;37# Setting the Access log 38access_log   logs/access.log&Nbsp; main;39client_header_timeout  3m;40client_body_timeout    3m;41send_ timeout          3m;42sendfile                 on;43tcp_nopush               on;44tcp_nodelay             on;45keepalive_timeout  65;4647# set server list for load Balancing 48upstream The  backserver {49#weigth parameter represents weights, the higher the weight, the greater the probability of being allocated 50# This example refers to the same server where multiple servers change IP 51server 127.0.0.1:8081  weight=5;52server 127.0.0.1:8082;53server 127.0.0.1:8083;54}    #Deny   access to any host other than  (WWW). 4535.com   server {        server_name  _;   #default         return 404;   }   55# set the virtual host, the default is to listen to 80 port, change to another port will be a problem 56server {57listen          80;58server_name    test.com www.test.com; 59charset utf8;60# set the Access log for this virtual host 61access_log  logs/test.com.log  main;62# if Access  / images/*, /js/*, /css/*  the resource, the local file is taken directly without forwarding. But if the file is more effective is not too good. 63location ~ ^/(IMAGES|JS|CSS)/  {64root    /usr/local/testweb; 65expires 30m;66}67# to   "/"   Enable load Balancing 68location / {69proxy_pass       http://backserver;70proxy_redirect          off; 71proxy_set_header        host  $host;72proxy_set_header         X-Real-IP  $remote _addr;73proxy_set_header         X-Forwarded-For  $proxy _ADD_X_FORWARDED_FOR;74CLIent_max_body_size    10m;75client_body_buffer_size 128k;76proxy_connect_timeout   90;77proxy_send_timeout      90;78proxy_read_timeout       90;79proxy_buffer_size      4k;80proxy_buffers           4 32k;81proxy_busy_buffers_size 64k;82proxy_ temp_file_write_size 64k;} 83# set to view the address of Nginx state, run ./config  to specify, default is not installed. 84location /nginxstatus {85stub_status             on;86access_log             on; 87auth_basic              "NginxStatus"; 88# Whether you want to access through a user name and password, you can test without adding. The contents of the conf/htpasswd  file are generated using the  apache   htpasswd  tools provided #auth_basic_user_file  conf /htpasswd;89}90}91

Apache Port changed to 8080.

This article is from the "Wang Shengguo Pool" blog, make sure to keep this source http://wangsheng1.blog.51cto.com/29473/1563235

CENTOS7 Nginx front-end Apache backend and multi-site simple 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.