php - Base URLs like example.com not working in NGinx -


i have 12 sites plan run on single server has nginx , php5-fpm on it. set them using 1 server block per conf file, included main nginx.conf file. it's mix of wordpress, phpmyadmin, , php sites. wordpress , phpmyadmin sites working fine, php sites not. meaning, when pull example.com, chrome says connection refused, , there's no trace of incoming connection on nginx logs. test.example.com pulls default site(because didn't configure test.example.com then) @ same time.

i copied nginx configs working sites set sites not working, no luck. difference in nginx config between working , non-working sites server_name directive.

after checking , rechecking on 2 hours, found out sites have server_name pqr.example.com work, ones example.com don't. of working sites configured use subdomain urls, , that's why they're working.

my questions -
1. missing in config make abc.com work ?
2. have 2 sites, example.com , example.net i'm trying run on same server. going problem nginx ?
3. nginx have problem differentiating between example.com, test.example.com, , example.net ?
4. noticed if www.example.net works, www.example.com doesn't , vice versa, means have assign each site has name abc in different subdomains www.example.net , test.example.com. standard/expected behavior of nginx, or missing ?
5. of base urls auto redirect http://example.com http://www.example.com; how find out redirect happening ?

below nginx config files i'm having problems with, truncated include important parts; please let me know if more info needed.

main nginx.conf file -

user www-data www-data; pid /var/run/nginx.pid; worker_processes 4; worker_rlimit_nofile 100000;  events {     worker_connections  4096;     include /etc/nginx.custom.events.d/*.conf; }  http {     default_type application/octet-stream;      access_log off;     error_log  /var/log/nginx/error.log crit;     .......     server_tokens off;      include proxy.conf;     include fcgi.conf;      include conf.d/*.conf;     include /etc/nginx.custom.d/*.conf; }  include /etc/nginx.custom.global.d/*.conf; 

here full working .conf file blog works. other sites have full config, since basic php sites.

server {     listen *:80;          server_name blog.example.com;      access_log /var/log/nginx/blog-example.access.log;     error_log /var/log/nginx/blog-example.error.log;      root /var/www/example/blog;     index index.html index.htm index.php;      # order might seem weird - attempted match last if rules below fail.     location / {         try_files $uri $uri/ /index.php?$args;     }      # add trailing slash */wp-admin requests.     rewrite /wp-admin$ $scheme://$host$uri/ permanent;      # directives send expires headers , turn off 404 error logging.     location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {            access_log off; log_not_found off; expires max;     }      location = /favicon.ico {         log_not_found off;         access_log off;     }      location = /robots.txt {         allow all;         log_not_found off;         access_log off;     }      # deny attempts access hidden files such .htaccess, .htpasswd, .ds_store (mac).     # keep logging requests parse later (or pass firewall utilities such fail2ban)     location ~ /\. {         deny all;     }      # deny access files .php extension in uploads directory     # works in sub-directory installs , in multisite network     # keep logging requests parse later (or pass firewall utilities such fail2ban)     location ~* /(?:uploads|files)/.*\.php$ {         deny all;     }      location ~ [^/]\.php(/|$) {          # zero-day exploit defense.         # http://forum.nginx.org/read.php?2,88845,page=3         # won't work (404 error) if file not stored on server, entirely possible php-fpm/php-fcgi.         # comment 'try_files' line out if set php-fpm/php-fcgi on machine.  , cross fingers won't hacked.         try_files $uri =404;         fastcgi_split_path_info ^(.+\.php)(/.+)$;          fastcgi_index index.php;         include fcgi.conf;         fastcgi_pass unix:/var/run/php-fcgi-blog-example-php-fcgi-0.sock;         fastcgi_param script_filename $document_root$fastcgi_script_name;      }  } 

here's truncated .conf file example.com

server {     listen *:80;          server_name example.com www.example.com test.example.com;      access_log /var/log/nginx/examplecom.access.log;     error_log /var/log/nginx/examplecom.error.log;      root /var/www/example/com;     index index.html index.htm index.php;      # order might seem weird - attempted match last if rules below fail.     location / {         try_files $uri $uri/ /index.php?$args;     }     ........      location ~ [^/]\.php(/|$) {         ......         fastcgi_index index.php;         include fcgi.conf;         fastcgi_pass unix:/var/run/php-fcgi-examplecom-php-fcgi-0.sock;         fastcgi_param script_filename $document_root$fastcgi_script_name;     }  } 

here's truncated file example.net

server {     listen *:80;      server_name example.net www.example.net test.example.net;      access_log /var/log/nginx/examplenet.access.log;     error_log /var/log/nginx/examplenet.error.log;      root /var/www/example/net;     index index.html index.htm index.php;      # order might seem weird - attempted match last if rules below fail.     location / {         try_files $uri $uri/ /index.php?$args;     }     ........      location ~ [^/]\.php(/|$) {         ......         fastcgi_index index.php;         include fcgi.conf;         fastcgi_pass unix:/var/run/php-fcgi-examplenet-php-fcgi-0.sock;         fastcgi_param script_filename $document_root$fastcgi_script_name;     } } 

meaning, when pull example.com, chrome says connection refused, , there's no trace of incoming connection on nginx logs. test.example.com pulls default site(because didn't configure test.example.com then) @ same time.

well, server listening. chances haven't configured dns records correctly, or there dns caching. set host file test theory.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -