Home php教程 php手册 用Apache反向代理设置对外的WWW和文件服务器

用Apache反向代理设置对外的WWW和文件服务器

Jun 13, 2016 pm 12:43 PM
apache acting reverse and Access document server machine use of Introduction set up


简介:一台机器用专线接入Internet作为防火墙,在内部网段上有一台WWW服务器 
(Redhat 6.1,Apache 1.3.9)希望这台机器能对外提供WWW服务器和基于apache 
的文件服务。供外部世界公共访问WWW服务器,或者外地分公司下载需要的文件。 
优点: 内部的WWW服务器和文件服务完全与外部世界隔开,不直接连接到外部,通过 
防火墙上运行的Apache服务提供对内部的代理访问,增强了安全性,同时在 
防火墙上运行的Apache服务运用基于名字的虚拟主机技术,使得防火墙上的 
主页不会被访问到。符合了作为防火墙要求运行服务越少越安全的准则。 

实现方法:在内部网段上的Apache服务器(192.168.11.2)存放的是公司主页,供内部 
和外部用户公共访问,并设置/home/ftp/pub目录为文件存放区域,用 
http://download.yourdomain.com/pub/来访问。 
在防火墙上设置apache反向代理技术,由防火墙代理对内部网段上的访问。 

步骤: 
一. 内部网段上的Apache服务器设置 

apache采用默认配置。主目录为/home/httpd/html,主机域名为 sun.yourdomain.com, 
且别名www.yourdomain.com, 并且设置srm.conf加一行别名定义如下: 
Alias /pub /home/ftp/pub/ 

且更改默认应用程序类型定义如下: 
DefaultType application/octet-stream 

最后在/etc/httpd/conf/access.conf中增加一项定义 

Options Indexes 
AllowOverride AuthConfig 
order allow,deny 
allow from all 

注:Options Indexes允许在找不到index.html文件的情况下允许列出目录/文件列表。 
AllowOverride AuthConfig允许做基本的用户名和口令验证。 
这样的话,你需要在/home/ftp/pub目录下放入.htaccess,内容如下: 
------- 
[root@shopu pub]# more .htaccess 
AuthName Branch Office Public Software Download Area 
AuthType Basic 
AuthUserFile /etc/.usrpasswd 
require valid-user 
------ 
然后用#htpasswd -c /etc/.usrpasswd user1 
分别创建不同的允许访问/pub下文件服务的外部用户名和口令。 


二. 防火墙上反向代理配置: 
加下面的行到/etc/httpd/conf/httpd.conf 

NameVirtualHost 1.2.3.4 

# 1.2.3.4是防火墙外部网卡的互联网上永久IP地址 


servername www.yourdomain.com 
errorlog /var/log/httpd/error_log 
transferlog /var/log/httpd/access_log 
rewriteengine on 
proxyrequests off 
usecanonicalname off 
rewriterule ^/(.*)$ http://192.168.11.2/$1 [P,L] 


servername download.yourdomain.com 
errorlog /var/log/httpd/download/error_log 
transferlog /var/log/httpd/download/access_log 
rewriteengine on 
proxyrequests off 
usecanonicalname off 
rewriterule ^/(.*)$ http://192.168.11.2/$1 [P,L] 


注:设置防火墙上的DNS,让download.yourdomain.comwww.yourdomain.com都指向 
防火墙的外部网卡地址。www.yourdomain.com防问你的公司主页, 用 
http://download.yourdomain.com/pub/...参募略厍?/a> 


你需要在内部网段的apache主机上建立目录/var/log/httpd/download/目录,否则会 
出错。另外,你也可以设置防火墙主机上的/home/httpd/html/index.html的属性为 
750

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

How to add a server in eclipse How to add a server in eclipse May 05, 2024 pm 07:27 PM

To add a server to Eclipse, follow these steps: Create a server runtime environment Configure the server Create a server instance Select the server runtime environment Configure the server instance Start the server deployment project

Application of algorithms in the construction of 58 portrait platform Application of algorithms in the construction of 58 portrait platform May 09, 2024 am 09:01 AM

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

How to deploy and maintain a website using PHP How to deploy and maintain a website using PHP May 03, 2024 am 08:54 AM

To successfully deploy and maintain a PHP website, you need to perform the following steps: Select a web server (such as Apache or Nginx) Install PHP Create a database and connect PHP Upload code to the server Set up domain name and DNS Monitoring website maintenance steps include updating PHP and web servers, and backing up the website , monitor error logs and update content.

Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Jul 23, 2024 pm 09:34 PM

According to news from this website on July 23, ASUS has launched a variety of server and workstation-level products powered by AMD EPYC 4004 series processors. Note from this site: AMD launched the AM5 platform and Zen4 architecture EPYC 4004 series processors in May, offering up to 16-core 3DV-Cache specifications. ASUSProER100AB6 server ASUSProER100AB6 is a 1U rack server product equipped with EPYC Xiaolong 4004 series processor, suitable for the needs of IDC and small and medium-sized enterprises. ASUSExpertCenterProET500AB6 workstation ASUSExpertCenterProET500AB6 is a

How to implement PHP security best practices How to implement PHP security best practices May 05, 2024 am 10:51 AM

How to Implement PHP Security Best Practices PHP is one of the most popular backend web programming languages ​​used for creating dynamic and interactive websites. However, PHP code can be vulnerable to various security vulnerabilities. Implementing security best practices is critical to protecting your web applications from these threats. Input validation Input validation is a critical first step in validating user input and preventing malicious input such as SQL injection. PHP provides a variety of input validation functions, such as filter_var() and preg_match(). Example: $username=filter_var($_POST['username'],FILTER_SANIT

How to leverage Kubernetes Operator simplifiy PHP cloud deployment? How to leverage Kubernetes Operator simplifiy PHP cloud deployment? May 06, 2024 pm 04:51 PM

KubernetesOperator simplifies PHP cloud deployment by following these steps: Install PHPOperator to interact with the Kubernetes cluster. Deploy the PHP application, declare the image and port. Manage the application using commands such as getting, describing, and viewing logs.

Tsinghua Optics AI appears in Nature! Physical neural network, backpropagation is no longer needed Tsinghua Optics AI appears in Nature! Physical neural network, backpropagation is no longer needed Aug 10, 2024 pm 10:15 PM

Using light to train neural networks, Tsinghua University results were recently published in Nature! What should I do if I cannot apply the backpropagation algorithm? They proposed a Fully Forward Mode (FFM) training method that directly performs the training process in the physical optical system, overcoming the limitations of traditional digital computer simulations. To put it simply, it used to be necessary to model the physical system in detail and then simulate these models on a computer to train the network. The FFM method eliminates the modeling process and allows the system to directly use experimental data for learning and optimization. This also means that training no longer needs to check each layer from back to front (backpropagation), but can directly update the parameters of the network from front to back. To use an analogy, like a puzzle, backpropagation

See all articles