0

I have a working nginx setup on AWS.

foo.domain.com is already mapped to a django server.

I am trying to change url from foo.domain.com to foo777.domain.com.

But after succesful nginx stop, reload, start the new url is not coming into effect. Nginx continues to serve old url foo.domain.com instead of foo777.domain.com

Here is what I have done so far. I change all the instances of word foo to foo777 in /etc/nginx/sites-available/foo which is symlinked to /etc/nginx/sites-enabled/foo. I can open the symlinked file in vi and verify that changes (foo->foo777) are succesffuly done in config.

sudo service nginx stop && sudo service nginx reload && sudo service nginx start
 * Stopping nginx nginx                                                                                                                 [ OK ] 
 * Reloading nginx configuration nginx                                                                                                  [ OK ] 
 * Starting nginx nginx                                                                                                                 [ OK ] 

But the nginx is still serving foo.domain.com instead of foo777.domain.com

I can do sudo service nginx stop and foo.domain.com is successfully stopped; checked from browser.

I can do sudo service nginx start and foo.domain.com is successfully started; checked from browser.

For sake of completeness I do sudo service nginx reload and that gets successfully done without errors

I did sudo nginx -t and it reports

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

I did which nginx and it reports

/usr/sbin/nginx

I did nginx -V and it reports:

nginx version: nginx/1.2.6 (Ubuntu)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.2.6/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.2.6/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.2.6/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.2.6/debian/modules/nginx-dav-ext-module

The /etc/nginx/nginx.conf looks like this:

    user www-data;
    worker_processes 4;
    pid /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";

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

/etc/nginx/sites-enabled/foo looks like this:

server {
    listen       80;
    server_name  foo777.domain.com www.foo777.domain.com;

    access_log   /var/log/nginx/domain.access.log;
    error_log    /var/log/nginx/domain.error.log;
    root /home/user/foo/;

    location  /static/ {
        alias  /home/user/foo/static/;
    }

    location  / {
        proxy_pass            http://127.0.0.1:8700;
        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;
        proxy_read_timeout    7200;
        client_max_body_size  10m;
    }

    allow all;
}

Everything seems normal and no error is reported anywhere except that foo777.domain.com is not being served.

I have restarted the AWS instance too but didn't affect anything either. Nginx continues to serve the old url.

Any help in this regard will be greatly appreciated.

Thanks.

__

@tedder42

Edit 1:

Pasting the output of various diagnostic commands:

Command 1:

atd@atd-ub14:~$ curl -D - http://foo777.domain.com
curl: (6) Could not resolve host: foo777.domain.com

Command 1 after some time:

atd@atd-ub14:~$ curl -D - http://foo777.domain.com
curl: (7) Failed to connect to foo777.domain.com port 80: Connection timed out

Commmand2:

atd@atd-ub14:~$ curl -D - http://foo.domain.com
HTTP/1.1 301 MOVED PERMANENTLY
Server: nginx/1.2.6 (Ubuntu)
Date: Sat, 12 Dec 2015 06:38:30 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: http://foo.domain.com/login
Set-Cookie: sessionid=75eved1hfktbfrigiu063ny9dybltvma; httponly; Path=/

__

Edit 2:

Output of netstat -tulpn | grep nginx

netstat -tulpn | grep nginx
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      22932/nginx     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      22932/nginx  
Ashish Anand
  • 522
  • 6
  • 11

2 Answers2

0

Just try making some syntax error in the configuration file and try nginx -t, to make sure that you are editing the correct file.

Ligo George
  • 819
  • 2
  • 9
  • 21
0

As pointed out by Alexey Ten, it turns out a new dns setting for foo777 had to be entered. This is so unlike Google App Engine's way. Thanks for the help Alexey.

Ashish Anand
  • 522
  • 6
  • 11