0

Even though I change the root directive to point to /var/www/html, nginx is attempting to load files out of /var/www as my root directory.

I have restarted nginx and received "OK" after changing default.conf.

Am I doing something wrong? Worth nothing, this nginx server is running inside a docker container.

==================================

/etc/nginx/nginx.conf

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

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile off;
        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_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 /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
}

/etc/nginx/conf.d/default.conf

server {
    listen 80 default_server;
    server_name _;
    index  index.cfm index.html index.htm;
    root   /var/www/html;
    server_name_in_redirect off;

    set $path_info $request_uri;

    try_files $uri /index.cfm?$args;

    location ~* \.(cfm|cfc|cfr)$ {
        proxy_pass http://127.0.0.1:8888;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header XAJP-PATH-INFO $path_info;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        send_timeout 600;
    }

}

nginx root not correct

1 Answers1

1

You have configured nginx to use this root path for your website. This applies to static resources served by nginx.

However, your application server doesn't use nginx root option, since it is independent from nginx.

You need to fix your application server configuration.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Score! In my case, I needed to edit the Tomcat config `/usr/local/tomcat/conf/server.xml` to change the `docBase` reference to `/var/www/html`. Thanks Tero! – Brian FitzGerald Aug 23 '16 at 14:30