Proxy pass set body on if

sanflores nginx-forum at forum.nginx.org
Tue Feb 16 15:00:47 UTC 2021


I have an Angular app and need to use puppeteer for SSR. In order to make it
work I need to send the request with the body but I can't figure how to make
these things work together. 

        if ($limit_bots = 1){
                proxy_pass http://localhost:3000/puppeteer/download/html/;
                proxy_method GET;
                proxy_set_header content-type "application/json";
                proxy_pass_request_body off;
                proxy_set_body "{\"url\":\"https://$request\"}";
        }


        location ~ /index.html|.*\.json$ {  # Don't cache index.html and
*json files
          expires -1;
          add_header Cache-Control 'no-store, no-cache, must-revalidate,
proxy-revalidate, max-age=0';
          include /etc/nginx/security-headers.conf;
        }


The idea would be to redirect bots to the static html that will be provided
by puppeteer runing in another server, and adding proxy_server inside an if
is deprecated. I should be using a rewrite statement... but I can't set the
body.


Thank you in advance!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,290773,290773#msg-290773



More information about the nginx mailing list