2

I am trying to run nginx and hhvm with docker-compose and socket file configuration but it returns a 502 error. I can access to conf/hhvm/run/ from nginx and hhvm image. In the error.log nginx's file I got:

[error] 5#5: *3 connect() to unix:/var/run/hhvm/hhvm.sock failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/hhvm/hhvm.sock:", host: "xxxxxxx.io", referrer: "http://xxxxxxx.io/"

docker-compose file:

nginx:
  image: nginx
  restart: always
  ports:
    - 80:80
  log_driver: syslog
  links:
    - hhvm
  volumes:
    - ./www:/var/www/wp:rw
    - ./conf/nginx:/etc/nginx:rw
    - ./log/nginx:/var/log/nginx
    - ./conf/hhvm/run:/var/run/hhvm

hhvm:
  image: diegomarangoni/hhvm
  volumes:
    - ./log/hhvm:/var/log/hhvm
    - ./conf/hhvm/run:/var/run/hhvm
    - ./conf/hhvm:/etc/hhvm:rw
  command: hhvm -u nginx -m server -vServer.Type=fastcgi -vLog.Level=Verbose

Nginx:

nginx.conf file:

user  nginx;
worker_processes  1;
pid        /var/run/nginx.pid;

events {
  worker_connections  2048;
  multi_accept on;
  use epoll;
}

http {
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

  access_log  /var/log/nginx/access.log  main;
  error_log   /var/log/nginx/error.log;


  server_tokens off;
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 15;
  types_hash_max_size 2048;
  include /etc/nginx/mime.types;

  default_type application/octet-stream;
  gzip on;
  gzip_disable "msie6";
  open_file_cache max=100;

  server {
    listen       80;
    server_name xxxxxxx.io;
    root /var/www/wp;
    index index.html index.htm index.hh index.php;
    include /etc/nginx/hhvm.conf;

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

hhvm.conf:

location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_pass   unix:/var/run/hhvm/hhvm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

Hhvm:

php.ini:

; php options
session.save_handler = files
session.save_path = /var/lib/hhvm/sessions
session.gc_maxlifetime = 1440

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false

server.ini:

; php options

pid = /var/run/hhvm/pid

; hhvm specific

hhvm.server.file_socket=/var/run/hhvm/hhvm.sock
hhvm.server.type = fastcgi
hhvm.server.default_document = /var/www/wp/index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc

Edit: I got a new error if I use jolicode/hhvm image instead of diegomaragon/hhvm:

hhvm_1  | WARNING: Logging before InitGoogleLogging() is written to STDERR
hhvm_1  | E1214 23:22:35.751377     1 fastcgi-server.cpp:104] 13failed to bind to async server socket: 0.0.0.0:80: Permission denied
hhvm_1  | Permission denied listening on port 80
hhvm_1  | Unable to start page server
hhvm_1  | Shutting down due to failure(s) to bind in HttpServer::runAndExitProcess
docker_hhvm_1 exited with code 1
  • 1
    They are in different containers. You should use a network connection, not a socket. – Michael Hampton Dec 15 '15 at 1:05
  • @MichaelHampton I got the same error Connection refused) while connecting to upstream, client: 172.17.0.1, server: xxxxx.io, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxxxxx.io" with diegomarangoni/hhvm image and with jolicode/hhvm I got hhvm_1 | Unable to open pid file www.pid for write. However iptables -L returns ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:http ACCEPT tcp -- anywhere 172.17.0.3 tcp dpt:9000 – Avel Dec 15 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.