Setting up varnish in docker, nginx, php-fpm

37 Views Asked by At

I need all api.test.local/app/pub requests to work through varnish. I have my own docker container named fpm, in which php-fpm and nginx are running, and I want to put varnish there

default.vcl

vcl 4.1;
backend default {.host = "api.test.local";.port = "80";}
sub vcl_recv {if (req.url ~ "^/app/pub") {set req.backend_hint = default;}}
sub vcl_backend_response {if (bereq.url ~ "^/app/pub") {set beresp.ttl = 5m;}}

nginx.conf

server { include settings/shared/listen_80.conf;
root /projects/test/server/web;

index dev.php;
charset utf-8;

server_name test.local start.test.local api.test.local admin.test.local back.test.local backoffice.test.local web1.test.local web.test.local wv.test.local apimanager.test.local apiservice.test.local;
add_header X-Frame-Options "ALLOW-FROM $current_origin" always;
add_header 'Access-Control-Expose-Headers'    'Api-Session' always;

include settings/server/api-cors-headers.conf;

if ($request_method = 'OPTIONS') {
    return 204;
}
location /app/pub {
    proxy_pass http://fpm:6081;
}
include settings/server/root_location.conf;
include settings/shared/internal_php_location.conf;}

root_location.conf

location / { try_files $uri /dev.php$uri?$args; }

I get an error `<!DOCTYPE html>

0

There are 0 best solutions below