Question

None of my configurations is taking effect on Nginx

I have a dedicated DreamHost Server where I installed a ruby on rails app under /srv directory, I installed nginx with passenger and configured nginx to open my app when I access my domain which is the server name .dreamhost.com. However, it is still showing welcome to nginx page even if I run sudo /etc/init.d/nginx reload or stop or service nginx stop I get no error but nothing changes and I keep getting the welcome page as if the restart or stop didn’t take any effect. Also I tried to remove nginx but nothing changed. This is my /etc/nginx/nginx.conf file:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
	worker_connections 768;
	# multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

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

	##
	# Logging Settings
	##

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

	##
	# Gzip Settings
	##

	gzip on;
	gzip_disable "msie6";

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# nginx-naxsi config
	##
	# Uncomment it if you installed nginx-naxsi
	##

	#include /etc/nginx/naxsi_core.rules;

	##
	# nginx-passenger config
	##
	# Uncomment it if you installed nginx-passenger
	##
	
	passenger_root /home/madrasati/.rvm/gems/ruby-1.8.7-head/gems/passenger-5.1.2;
	passenger_ruby /home/madrasati/.rvm/gems/ruby-1.8.7-head/wrappers/ruby;
#	include /etc/nginx/passenger.conf;

	##
	# Virtual Host Configs
	##

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


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}

This is etc/nginx/sites-available/myapp file

server {
	listen 80 default_server;
	server_name www.madrasatie.com *.madrasatie.com ds10316.dreamservers.com;
	passenger_enabled on;
	passenger_app_env production;
	root /srv/fedena_app/fedena_cds/public;
}

And this is /home/madrasatie/nginx/madrasatie:

server {
	listen 80 default_server;
	server_name www.madrasatie.com *.madrasatie.com *.208.97.137.194;
	passenger_enabled on;
	passenger_app_env production;
	root /srv/fedena_app/fedena_cds/public;
}



I tried so many things and nothing is taking effect. Please help me solve this.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@raafathamzeh

include /etc/nginx/sites-enabled/*;

The above line tells NGINX to pull all website related configuration files from sites-enabled, so if you aren’t symlinking configuration files from sites-available to sites-enabled, then NGINX is loading the first or default configuration that it’s shipped with (normally named default).

When you run:

ls /etc/nginx/sites-available

… you should see a file called default or default.conf. This is the actual file. Now when you run:

ls /etc/nginx/sites-enabled

… the file you see there is the symlink (a link to the file in sites-available). You can safely delete that file as it’s just meant to be used as an example to get you started.

That being said, configuration will only be loaded from where you tell NGINX in nginx.conf, so if you don’t want to bother with symlinks (which can be a pain at times), I’d change this line:

include /etc/nginx/sites-enabled/*;

to

include /etc/nginx/sites-available/*;

… and save nginx.conf.

As for your actual configuration for your site/app, all configuration should be stored in one of the directories above (sites-available or siites-enabled) – if you do what I recommended above, then that would be sites-available. You don’t need to store configuration files for NGINX in a public directory (which appears to be the case for the second that you mention).

So if you have two configuration files for two sites, then you should have something such as:

/etc/nginx/sites-available/mysite01.conf
/etc/nginx/sites-available/mysite02.conf

Other than that, both of the configuration files you’ve posted are marked as default_server. This should only be defined for one configuration file, or not at all, else NGINX is going to throw an error.

Also, I always recommend cleaning up any configuration to prevent potential issues, so below is an exact copy of your NGINX configuration with all the un-needed filler, just to keep things clean.

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

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

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

    gzip on;
    gzip_disable "msie6";

    passenger_root /home/madrasati/.rvm/gems/ruby-1.8.7-head/gems/passenger-5.1.2;
    passenger_ruby /home/madrasati/.rvm/gems/ruby-1.8.7-head/wrappers/ruby;
    #include /etc/nginx/passenger.conf;

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

@raafathamzeh

The apt-get remove ... command won’t remove NGINX configuration files – only packages.

Anything that was added by NGINX – such as configuration files – or anything you’ve added – also such as configuration files – won’t be removed; that’d be what apt-get purge ... is for.

i.e.

sudo apt-get purge nginx

or

sudo apt-get purge nginx-*

It is important to note, however, if you run purge, it will delete anything you’ve added. If you need to backup your existing configuration for reference, please do that before running the command.

Once NGINX is removed/purged, you can reinstall it using:

sudo apt-get -y install nginx-full

Once NGINX is installed, you can begin to reconfigure.

@raafathamzeh

Please run this command to test your configuration first.

service nginx configtest

And you cannot have two server-sections competing for the same domain. And you cannot use wildcard (the *) like that with IP-addresses. And you have probably not added your server-section configurations to /etc/nginx/sites-enabled.

Then remember to run service nginx configtest and then service nginx reload after every change, so you test the configurations before rebooting nginx.

By the way, you do know that DigitalOcean is a competing company to DreamHost Servers ?