You are not logged in.

#1 2014-01-26 23:17:55

duke11235
Member
Registered: 2009-10-09
Posts: 221

[SOLVED]Nginx Virtual Hosts Conf Issues

I have a server with nginx installed and setup, then I acquired an additional domain. I created a virtual hosts file and symlinked it to

/etc/nginx/sites-enabled

Trouble is that I seem to have screwed up ghost install, and I can't quite figure out how the config works. There are also server blocks in nginx.conf that nginx complains about if they are in sites-enabled and in nginx.conf. I don't have the default nginx.conf file anymore, and I can't find it online, so here's what I have in the relevant files:

nginx.conf

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

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    proxy_cache_path  /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
    proxy_temp_path /var/tmp;
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

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

    upstream ghost_upstream {
      server 127.0.0.1:2368;
      keepalive 64;
    }
}

sites-available

# You may add here your
# server {
#       ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www/example/public_html;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name example.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
}

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

Do I need server blocks in both nginx.conf and sites-enabled?
Any help getting back online would be greatly appreciated.

Last edited by duke11235 (2014-01-27 00:58:01)

Offline

#2 2014-01-26 23:36:11

damjan
Member
Registered: 2006-05-30
Posts: 452

Re: [SOLVED]Nginx Virtual Hosts Conf Issues

are those the complete config files??

each virtual host will need a separate 'server { }' section which will need to have a 'listen ...;' and a 'server_name ....;' directive.


ps.
If you move the /etc/nginx/nginx.conf file somewhere, and reinstall nginx you'll get back the original config file.
The default config file doesn't include files from sites-enabled/ though. And if you add that yourself make sure it's in the 'http {}' section, and not in another 'server {}' section.

Offline

#3 2014-01-27 00:57:46

duke11235
Member
Registered: 2009-10-09
Posts: 221

Re: [SOLVED]Nginx Virtual Hosts Conf Issues

I got it now. I needed some proxypass parameters and to include the sites enabled folder in the http section of nginx.conf. Thanks

Offline

Board footer

Powered by FluxBB