Davis' Alt Notes

Reverse Proxy

Reverse proxy is another type of proxy server working between clients and servers. Unlike normal proxy servers (namely, forward proxy) which are usually established at the client side for internal users to access the external network (e.g. Internet), reverse proxy servers usually works at the server side exposing internal services to the external network. In a simple word, forward proxy servers are agents for clients, while reverse proxy servers are agents for servers.

ℹ️ Many Google Scholar users in China often use reverse proxy to establish mirrors of Google Scholar allowing anyone to access it from China without being blocked by the Great Firewall.

It will be useful if you are a server maintainer. Lots of dynamic web services expose their HTTP services through a port number other than 80 by default, and it’s also not realistic to change their port settings to 80 if you have other HTTP services in the same server. With reverse proxy and the Virtual Hosts feature of web server (a.k.a. server blocks in Nginx), you can make all of them share the 80 port.


Create a site configuration in /etc/nginx/sites-available:

server {
        listen 80;
        listen [::]:80;

        server_name example.com;

        location / {

Replace value of server_name to the domain you bind with this service, and proxy_pass should be the local binding location of your service. After that, enable the configuration and reload Nginx service.


In order to use proxy features of Apache, enable two mods mod_proxy and mod_proxy_http:

sudo a2enmod proxy proxy_http

Create configuration:

<VirtualHost *:80>
        ServerName manage.momok.xyz
        ServerAdmin [email protected]

        ProxyRequests Off
        ProxyMaxForwards 100
        ProxyPreserveHost On

        ProxyPass /
        ProxyPassReverse /

        <Proxy *>
            Order Deny,Allow
            Allow from all

After that, enable the configuration and reload Apache service:

sudo a2ensite proxy.conf
sudo service apache2 restart

, , β€” Aug 21, 2020