标签归档:linux appache

apache正向代理,通过服务器ip访问网站,实现服务器的图形化浏览网页

apache配置正向代理,实现通过服务器ip访问某个指定网站

apache需要加载代理模块

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_scgi_module modules/mod_proxy_scgi.so

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

然后修改httpd-vhost.conf配置文件,实现代理转发功能.

Listen 3909
NameVirtualHost *:3909
<VirtualHost *:3909>
    ProxyRequests On
    ProxyVia On
    ProxyTimeout 60
    AllowCONNECT 9445 8181 8051 443 8001 80 8005 8500 37031 37032
    KeepAlive off
    LogLevel emerg
    CustomLog /dev/null common
    ErrorLog /dev/null
    <Proxy *>
            Order deny,allow
            Deny from all
            Allow from all
    </Proxy>
</VirtualHost>

httpd 两种工作类型prefork和worker工作模式

Apache is the most common and famous webserver. Everyone knows about apache and most of us also have hands on experience with apache. But few of us know that apcahe2 comes with 2 multi processing modules(MPMs):

1. Prefork
2. Worker

 

What is the difference between this two?

Prefork MPM uses multiple child processes with one thread each and each process handles one connection at a time.

Worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time.

On most of the systems, speed of both the MPMs is comparable but prefork uses more memory than worker.

 

Which one to use?

On high traffic websites worker is preferable because of low memory usage as comparison to prefork MPM but prefork is more safe if you are using libraries which are not thread safe.

For example you cannot use mod_php(not thread safe) with worker MPM but can use with prefork.

So if you are using all thread safe libraries then go with worker and if you are not sure then use default prefork MPM, you may have to increase your RAM in case of high traffic.

If you are on linux then run following command to check which MPM is on your machine

/usr/sbin/apache2 -V | grep MPM