Puma and Nginx Configuration not Working in AWS production server

Hi,

I got a fresh copy of Zammad 3.2 from the GitHub repository.
And I just setup Zammad on an AWS Ubuntu 18.04 production server.
I have installed Ruby on Rails, Elasticsearch, PostgreSQL and other dependencies on the server.

I am using Rails default application server (PUMA) as the application server and I have installed Nginx as the reverse proxy server, but the application throws a 500 error page when I try to access it via the public IP Address of the AWS Server where it is deployed.

I think the issue is from my Nginx Configuration and/or the Puma Configuration.

Here is my Nginx Configuration (nginx/zammad.conf)

upstream zammad {
    # Path to Puma SOCK file, as defined previously
    server unix:/home/ubuntu/zammad/shared/sockets/puma.sock fail_timeout=0;
}

server {
    listen 80;

    server_name localhost;

    root /home/ubuntu/zammad/public;
    try_files $uri/index.html $uri @zammad;

    location @zammad {
        proxy_pass http://zammad;
        proxy_set_header Host $http_host;
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 50M;
    keepalive_timeout 10;

    gzip on;
    gzip_types text/plain text/xml text/css image/svg+xml application/javascrip$
    gzip_proxied any;
}

And this is the Puma Configuration (zammad/config/puma.rb)

# Change to match your CPU core count
workers 2

# Min and Max threads per worker
threads 1, 6

app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"

# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env

# Set up socket location
bind "unix://#{shared_dir}/sockets/puma.sock"

# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.st$

# Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"
activate_control_app

on_worker_boot do
  require "active_record"
  ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotE$
  ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/dat$
end

Infos:

  • Used Zammad version: Zammad v3.2.0
  • Used Zammad installation source: git repository source
  • Operating system: Ubuntu 18.04
  • Browser + version: Google Chrome v77

Expected behavior:

  • I expect to see the homepage/index page of Zammad when I enter the Public IP Address of the AWS Server where the copy of Zammad is hosted.

Actual behavior:

Steps to reproduce the behavior:

  • Setup a new AWS server
  • Install Ruby on Rails, Elasticsearch, Nginx on the server
  • Clone a copy of Zammad from GitHub to the server.

Thank you in advance for your assistance.

Please provide logfiles~

Here is short output of the error log

2019/11/06 11:23:43 [info] 6361#6361: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2019/11/06 11:24:07 [crit] 6391#6391: *3 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connectin$
2019/11/06 11:24:13 [crit] 6391#6391: *8 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connectin$
2019/11/06 11:26:23 [info] 6468#6468: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2019/11/06 11:27:23 [crit] 6497#6497: *1 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connectin$
2019/11/06 11:27:30 [crit] 6497#6497: *8 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connectin$
2019/11/06 11:37:44 [crit] 6497#6497: *11 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connecti$
2019/11/06 11:37:48 [crit] 6497#6497: *11 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connecti$
2019/11/06 11:39:17 [crit] 6497#6497: *15 connect() to unix:/home/ubuntu/zammad/shared/sockets/puma.sock failed (2: No such file or directory) while connecti$

Sorry but I can’t help you with sockets.
Normally you’d want to connect to http://127.0.0.1:3000

You changed the configuration file that we provide, I’m sure you had a reason for this.-

1 Like

Oh, thank you so much for your response.

I was following a tutorial, and that was why my configuration looked that way.

The little issue that I had with the configuration provided by Zammad is that I didn’t find the configuration for the Rails application server (PUMA), so I kept on scouting the internet for tutorials that had both the Nginx and PUMA configurations, since I am using the both servers.

If you can explain or have any Zammad documentation that explicitly outlines the recommended configuration for Nginx (web server) and Puma (application server), please point me to them, I will be very appreciative.

Thanks in advance.

Thank you, I have fixed it using Zammad’s Documentation

Here is the Nginx Configuration that I used

upstream zammad-railsserver {
server 127.0.0.1:3000;
}

upstream zammad-websocket {
    server 127.0.0.1:6042;
}

server {
    listen 80;

    # replace 'localhost' with your fqdn if you want to use zammad from remote
    server_name localhost;

    root /home/ubuntu/zammad/public;

    client_max_body_size 50M;

    location ~ ^/(assets/|robots.txt|humans.txt|favicon.ico) {
        expires max;
    }

    location /ws {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 86400;
        proxy_pass http://zammad-websocket;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300;
        proxy_pass http://zammad-railsserver;

        gzip on;
        gzip_types text/plain text/xml text/css image/svg+xml application/javas$
        gzip_proxied any;
    }
}

Here is the Puma Configuration that I used

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count_min = Integer(ENV['MIN_THREADS'] || 1)
threads_count_max = Integer(ENV['MAX_THREADS'] || 6)
threads threads_count_min, threads_count_max

environment ENV.fetch('RAILS_ENV', 'production')

preload_app!

on_worker_boot do
  ActiveRecord::Base.establish_connection
end

Thank you.

1 Like

Glad you could solve your issue :slight_smile:

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.