{"action":"created","issue":{"url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/241","labels_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/241/labels{/name}","comments_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/241/comments","events_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/241/events","html_url":"https://github.com/jwilder/nginx-proxy/issues/241","id":108059450,"number":241,"title":"Can't get proxy_cache to work","user":{"login":"Bockit","id":167362,"avatar_url":"https://avatars.githubusercontent.com/u/167362?v=3","gravatar_id":"","url":"https://api.github.com/users/Bockit","html_url":"https://github.com/Bockit","followers_url":"https://api.github.com/users/Bockit/followers","following_url":"https://api.github.com/users/Bockit/following{/other_user}","gists_url":"https://api.github.com/users/Bockit/gists{/gist_id}","starred_url":"https://api.github.com/users/Bockit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bockit/subscriptions","organizations_url":"https://api.github.com/users/Bockit/orgs","repos_url":"https://api.github.com/users/Bockit/repos","events_url":"https://api.github.com/users/Bockit/events{/privacy}","received_events_url":"https://api.github.com/users/Bockit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-24T05:10:04Z","updated_at":"2015-09-30T16:46:14Z","closed_at":null,"body":"Hi,\r\n\r\nI think I'm having trouble with nginx `proxy_cache` settings and nginx-proxy. I'm not sure if you want questions here so if you feel this would better be served asking elsewhere please let me know.\r\n\r\nI'm using nginx-proxy to reverse proxy to a node application running in a separate docker container on the same host.\r\n\r\nI've got a proxy configuration file `proxy.conf`:\r\n\r\n```nginx\r\nproxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:10m max_size=10g;\r\n```\r\n\r\nand a file for the virtual host specifying how the reverse proxy should cache responses `my.virtual.host_location`:\r\n\r\n```nginx\r\nproxy_cache one;\r\nadd_header X-Cached $upstream_cache_status;\r\n```\r\n\r\nThe `X-Cached` header always has `MISS`.\r\n\r\nWhen I set nginx up manually and exposed the port on the node app I was able to get `HIT`s. I assume I'm doing something incorrectly in my configuration but I really don't know how to tell why a request is a cache hit or not.\r\n\r\nHere's a sample set of response headers:\r\n\r\n```http\r\nAccess-Control-Allow-Origin → *\r\nCache-Control → max-age=12000\r\nConnection → keep-alive\r\nContent-Length → 189\r\nContent-Type → application/json; charset=utf-8\r\nDate → Thu, 24 Sep 2015 04:49:49 GMT\r\nETag → W/\"bd-aoxcrTy+QadpC3n9/+drVw\"\r\nServer → nginx/1.9.2\r\nVary → Accept-Encoding\r\nX-Cached → MISS\r\nX-Powered-By → Express\r\n```\r\n\r\nAnd here's my `docker-compose.yml`\r\n\r\n```yaml\r\nnginx:\r\n  restart: always\r\n  image: jwilder/nginx-proxy:latest\r\n  ports:\r\n    - 80:80\r\n  volumes:\r\n    - /var/run/docker.sock:/tmp/docker.sock:ro\r\n    - /etc/my-path/proxy.conf:/etc/nginx/conf.d/proxy.conf:ro\r\n    - /etc/my-path/vhost.d:/etc/nginx/vhost.d:ro\r\n\r\napi:\r\n  restart: always\r\n  image: docker.my.domain:5000/image:4.0.0\r\n  environment:\r\n    VIRTUAL_HOST: my.virtual.host\r\n    NODE_ENV: prod\r\n```\r\n\r\nI only just found out about the `_location` vhost files, I was originally trying with the original system and I had the same problems then too.\r\n\r\nThanks for your time."},"comment":{"url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/comments/144472437","html_url":"https://github.com/jwilder/nginx-proxy/issues/241#issuecomment-144472437","issue_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/241","id":144472437,"user":{"login":"md5","id":76367,"avatar_url":"https://avatars.githubusercontent.com/u/76367?v=3","gravatar_id":"","url":"https://api.github.com/users/md5","html_url":"https://github.com/md5","followers_url":"https://api.github.com/users/md5/followers","following_url":"https://api.github.com/users/md5/following{/other_user}","gists_url":"https://api.github.com/users/md5/gists{/gist_id}","starred_url":"https://api.github.com/users/md5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/md5/subscriptions","organizations_url":"https://api.github.com/users/md5/orgs","repos_url":"https://api.github.com/users/md5/repos","events_url":"https://api.github.com/users/md5/events{/privacy}","received_events_url":"https://api.github.com/users/md5/received_events","type":"User","site_admin":false},"created_at":"2015-09-30T16:46:14Z","updated_at":"2015-09-30T16:46:14Z","body":"I'd try setting it to a directory other than `/var/cache/nginx` that is explicitly owned by `www-data:www-data` for testing purposes to rule out anything related to Docker volumes specifically. Then I'd possibly open an issue over at `docker-nginx`.\r\n\r\nYou might try creating a more minimal test case by deriving from the `nginx` image directly with a config that you know works in a non-Docker scenario."}}