To support AMP pages over HTTPS using a CNAME, a reverse proxy must be set up.

To configure a reverse proxy and HTTP cache using Nginx web server, the following steps must be performed.

This procedure assumes that the Nginx web server is already in place and working:

1 - Create the folder for local caching

Create the folder in your chosen location:

~$ sudo mkdir /var/cache/nginx

Give the folder the correct permissions to allow access to the Nginx server:

~$ sudo chmod -R 777 /var/cache/nginx


2 - Configure proxy and cache using the Nginx server block

The following is an example of the Nginx default server block file containing the additional syntax required. The syntax for the reverse proxy and cache configuration is in red

In the example below, the placeholder < DNS > is used. The correct DNS entry will be provided by the Customer Success team.

Replace the placeholder with the correct DNS entry.

It is important that proxy_cache_path and proxy_temp_path are kept outside of the server block.

proxy_cache_path   /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=9000g inactive=1d;

proxy_temp_path    /var/cache/nginx/tmp;:

server {

           listen 80 default_server; 

           listen [::]:80 default_server;

           server_name _;

           location / {                        

                       proxy_cache my_cache;

                       proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;

                       proxy_ignore_headers Set-Cookie;

                       proxy_set_header     Host          $host;                       

                       proxy_set_header     X-Real-IP         $remote_addr;

                       proxy_set_header     X-Forwarded-For         $proxy_add_x_forwarded_for;

                       proxy_pass < DNS >;



3 - Nginx configuration test

After the changes are made to the Nginx server block file, run the Nginx configuration test to ensure syntax is ok.

4 - Restart the Nginx web server

Restart the Nginx web server to put the changes into place.


For information on how to set up a reverse proxy on AWS (Amazon Web Services), see this article.