Skip to content

Configuring Nginx (CentOS)

Joe Wollard edited this page Feb 24, 2014 · 4 revisions

Previous: Configuring pm2


CentOS's installation of Nginx is a little different than Ubuntu's in that there are no sites-available or sites-enabled directories. Instead, 'site' config files go in /etc/nginx/conf.d/ and must end with a .conf extension.

First, we need to clear out the example site config files.

sudo rm /etc/nginx/conf.d/*

Next, we'll create a config file for Mandrill.

/etc/nginx/conf.d/mandrill.conf

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        gzip on;
        gzip_disable "msie6";

        # Change this to your server's FQDN or ip address
        server_name localhost;

        location / {
                # If you configured pm2 to run Mandrill on another port,
                # use that same port here. Leave 'localhost' though.
                proxy_pass http://localhost:3001/;
        }
}

Poking A Hole In The Firewall

Nginx's installation process makes no attempt at configuring iptables for you; why would it when it doesn't know for sure what port(s) you'll need? Fortunately, it's not hard to do. In the example above, we're listening on port 80, so that's the port we need to open up.

sudo iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
sudo /etc/init.d/iptables save

Next: Install Meteor