AngularJS doesn’t work with third party pre-render service

I’m using AngularJS with SEO4Ajax. I run my website in docker container with nginx. I copied all the nginx configurations from SEO4Ajax to docker container. Seo4Ajax had created the snapshots, but the url ended with ?_escaped_fragment_= doesn’t work.

AngularJS Header

meta(name='fragment', content='!')

AngularJS Config

$locationProvider.html5Mode(true).hashPrefix('!');

Nginx Config

server {
    listen 80;
    sendfile off;
    expires 0;
    location / {
        root /usr/share/nginx/html;
        index index.html index.htm;
        try_files $uri @s4a_analyse $uri/ /index.html =404;

        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, OPTIONS';
    }

    ### This location determines if a request comes from bots
    location @s4a_analyse {

        ### If the request comes from a bot, proxy the request through /s4a_proxy location
        if ($http_user_agent ~* (google|bot|spider|pinterest|crawler|archiver|flipboardproxy|mediapartners|facebookexternalhit|insights|quora|whatsapp|slurp)) {
            rewrite ^(.*)$ /s4a_proxy last;
        }

        ### Uncomment the 3 following lines to support the _escaped_fragment_= parameter
        if ($args ~ "_escaped_fragment_=") { 
            rewrite  ^(.*)$  /s4a_proxy  last;
        }

        if ($http_from ~* .+) {
            rewrite ^(.*)$ /s4a_proxy last;
        }

        ### Otherwise serve /index.html
        rewrite ^(.*)$ /index.html last;
    }

    ### This location proxy requests coming from bots to SEO4Ajax
    ### You can update the resolver directive with your own DNS provider if needed
    location /s4a_proxy {
        set $s4a_domain 'https://api.seo4ajax.com/SEO4AJAX_TOKEN';
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        resolver 8.8.8.8 8.8.4.4;
        proxy_pass $s4a_domain$request_uri;
    }
}

Header

I tried to curl url to retrieve header, X-Powered-By: SEO4Ajax doesn’t produce. It should show seo4ajax header based on this.

curl -H "User-Agent: Bot" -I http://www.mywebsite.net

HTTP/1.1 200 OK
Date: Sun, 14 Apr 2019 07:08:56 GMT
Content-Type: text/html
Connection: keep-alive
Set-Cookie: __cfduid=d464769ca8ded696b9c1dcfd4ed5bc14c1555225736; expires=Mon, 13-Apr-20 07:08:56 GMT; path=/; domain=.mywebsite.net; HttpOnly
Accept-Ranges: bytes
Access-Control-Allow-Methods: GET, PUT, POST, OPTIONS
Access-Control-Allow-Origin: *
Cache-Control: max-age=0
Expires: Sun, 14 Apr 2019 07:08:56 GMT
Last-Modified: Sun, 14 Apr 2019 05:00:06 GMT
Strict-Transport-Security: max-age=315360000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Xss-Protection: 1; mode=block
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4c73d9f24871a542-NRT

For server, I used cloudflare forward to my digital ocean server droplet IP.

Expected Output:

curl -H “User-Agent: Bot” -I https://www.mywebsite.net

should produce X-Powered-By: SEO4Ajax in header

Source: AngularJS