0

I am working on Ruby on Rails app. I am using Vagrant and Chef. I am trying to configure Nginx as my web server to work on HTTPS.

I am more than sure that I am missing something in my Nginx configuration file. Here are my Nginx configuration files:

/etc/nginx/nginx.conf:

user www-data;
worker_processes  1;
daemon off;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
  worker_connections  1024;
}

http {

  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;

  access_log    /var/log/nginx/access.log;

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;

  keepalive_timeout  65;

  gzip  on;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_proxied any;
  gzip_vary off;
  gzip_types text/plain text/css application/x-javascript text/xml application/xml application/rss+xml application/atom+xml text/javascript application/javascript application/json text/mathml;
  gzip_min_length  1000;
  gzip_disable     "MSIE [1-6]\.";

  server_names_hash_bucket_size 64;
  types_hash_max_size 2048;
  types_hash_bucket_size 64;

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}

/etc/nginx/sites-enabled/olympus:

upstream olympus {
    server unix:///tmp/olympus.sock;
}

server {
    listen 4430 default deferred;
    listen [::]:4430;
    listen 8080;
    listen [::]:8080;

    server_name: *.olympus.dev;

    add_header   Strict-Transport-Security max-age=31104000;

    ssl                  on;
    ssl_certificate      /vagrant/.ssl/olympus.crt;
    ssl_certificate_key  /vagrant/.ssl/olympus.key;

    root /vagrant/public;

    location / {
        proxy_redirect     off;

        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

        #all requests are sent to the UNIX socket
        proxy_pass  http://olympus;
    }
}

Port-forwarding config from Vagrantfile:

config.vm.network :forwarded_port, guest: 8080, host: 80
config.vm.network :forwarded_port, guest: 4430, host: 443

Here is how I run Puma

bundle exec puma -b unix:///tmp/olympus.sock
Puma starting in single mode...
* Version 2.9.0 (ruby 2.1.2-p95), codename: Team High Five
* Min threads: 0, max threads: 16
* Environment: development
* Listening on unix:///tmp/olympus.sock
Use Ctrl-C to stop

Here is the error I get when I try to curl https://olympus.dev/:

curl: (7) Failed connect to olympus.dev:443; Connection refused
halfer
  • 19,824
  • 17
  • 99
  • 186
Moon
  • 33,439
  • 20
  • 81
  • 132
  • what's your rails application server? unicorn? – Wenbing Li Aug 15 '14 at 05:20
  • What error are you getting? Stacktrace? – sethvargo Aug 15 '14 at 14:27
  • @sethvargo, more details added. – Moon Aug 16 '14 at 07:00
  • I don't think pow is smart enough to do the wiring you think it is - I would recommend removing as many pieces as possible. What if your `curl` the URL on the server? Does it work? What are in your server logs? – sethvargo Aug 16 '14 at 13:19
  • @sethvargo: I am not using `pow` Interestingly, there is noting in nginx `error` or `access` logs – Moon Aug 16 '14 at 14:35
  • Can you verify that nginx is actually serving the application - let's take Vagrant completely out of the mix. Can you `curl https://localhost:4430` on that box? – sethvargo Aug 16 '14 at 15:14
  • @sethvargo: That's what I thought. Looks like nginx is not even running! Here is what I get: `curl: (7) Failed to connect to localhost port 4430: Connection refused` – Moon Aug 16 '14 at 16:07
  • @sethvargo: I also verified that nginx is running using `ps waux | grep nginx` --> `root 966 0.1 0.0 168 36 ? Ss Aug15 0:58 runsv nginx` – Moon Aug 16 '14 at 16:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/59456/discussion-between-moon-and-sethvargo). – Moon Aug 16 '14 at 18:53

0 Answers0