Apache and Nginx Implement reverse proxy

Source: Internet
Author: User

One, Apache (not recommended):
  1. Agent 80 Port:
    A. Configuration:

    B. Effect:

    C. configuration file Reference:
    ServerRoot "/ETC/HTTPD" Listen 80proxypass/http://admin.dollarphp.com/proxypassreverse/http://admin.dollarphp.com /include conf.modules.d/*.confuser apachegroup apacheserveradmin [email protected]<directory/> allowoverride nonerequire all Denied</directory>documentroot "/var/www/html" <directory "/var/www" > allowoverride nonerequire all Granted</directory><directory "/var/www/html" >Options Indexes Followsymlinksallowoverride Nonerequire all Granted</directory><ifmodule dir_module>DirectoryIndex Index.html</ifmodule><files ". ht*" >require all Denied</files>errorlog "Logs/error_log" LogLevel Warn<ifmodule Log_config_module>logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combine Dlogformat "%h%l%u%t \"%r\ "%>s%b" Common<ifmodule logio_module> logformat "%h%l%u%t \"%r\ "%>s%b \"% {referer}i\ "\"%{user-agent}i\ "%I%O" combinedio</ifmodule>customlog "Logs/access_log" comBined</ifmodule><ifmodule alias_module>scriptalias/cgi-bin/"/var/www/cgi-bin/" </IfModule>< Directory "/var/www/cgi-bin" >allowoverride noneoptions nonerequire all granted</directory><ifmodule MIME _module>typesconfig/etc/mime.typesaddtype application/x-compress. Zaddtype application/x-gzip. gz. Tgzaddtype text/html. Shtmladdoutputfilter includes .shtml</ifmodule> Adddefaultcharset Utf-8<ifmodule Mime_magic_module>mimemagicfile Conf/magic</ifmodule>enablesendfile Onincludeoptional conf.d/*.conf
  2. Agent 443 Port:
    A. Install Mod_ssl:
    yum  -y  install  mod_ssl

    B. Configuration:

    C. Effect:

    D. configuration file Reference:

    ServerRoot "/etc/httpd" Listen 80SSLProxyEngine onproxypass/https://www.baidu.com/proxypassreverse/https:// Www.baidu.com/Include conf.modules.d/*.confuser apachegroup apacheserveradmin [email protected]<directory/ >allowoverride nonerequire all Denied</directory>documentroot "/var/www/html" <Directory "/var/www" > allowoverride nonerequire all Granted</directory><directory "/var/www/html" >Options Indexes Followsymlinksallowoverride Nonerequire all Granted</directory><ifmodule dir_module>DirectoryIndex Index.html</ifmodule><files ". ht*" >require all Denied</files>errorlog "Logs/error_log" LogLevel Warn<ifmodule Log_config_module>logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combine Dlogformat "%h%l%u%t \"%r\ "%>s%b" Common<ifmodule logio_module> logformat "%h%l%u%t \"%r\ "%>s%b \"% {referer}i\ "\"%{user-agent}i\ "%I%O" Combinedio</ifmodule>customlog "logs/access_lOG "combined</ifmodule><ifmodule alias_module>scriptalias/cgi-bin/"/var/www/cgi-bin/"</IfModule ><directory "/var/www/cgi-bin" >allowoverride noneoptions nonerequire all granted</directory>< Ifmodule Mime_module>typesconfig/etc/mime.typesaddtype application/x-compress. Zaddtype application/x-gzip. gz. Tgzaddtype text/html. Shtmladdoutputfilter includes .shtml</ifmodule> Adddefaultcharset Utf-8<ifmodule Mime_magic_module>mimemagicfile Conf/magic</ifmodule>enablesendfile Onincludeoptional conf.d/*.conf
    Two, Nginx (for both 80-port and 443-port):
  3. Configuration:
  4. Configuration file Reference:
    User Nginx;worker_processes auto;error_log/var/log/nginx/error.log;pid/run/nginx.pid;include/usr/share/nginx/ modules/*.conf;events {worker_connections 1024;}  HTTP {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/access.log ma In;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 2048;in Clude/etc/nginx/mime.types;default_type Application/octet-stream;include/etc/nginx/conf.d/*.conf;serv    er {listen default_server;    Listen [::]:80 default_server;    server_name _;    root/usr/share/nginx/html;    include/etc/nginx/default.d/*.conf;    Location/{Proxy_pass https://www.baidu.com;        } error_page 404/404.html;        Location =/40x.html {} error_page 502 503 504/50x.html;Location =/50x.html {}}} 

Apache, nginx implement reverse proxy

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.