Reputation: 35
I'm having the following issue :
My centos 7 vps is configured with nginx and two server-blocks (vhosts)
For both domains I can access the web-page using www.domain.tld but not using domain.tld.
No error or access logs are generated when accessing domain.tld
Dns record were checked and are pointing to the servers IP address with an empty A record ( the same dns record worked properly when server was configured with ubuntu 18.04, iRedMail, nextcloud and two websites).
The error message in browser is : "This site can’t be reached. domain.tld refused to connect."
Below are the config files (nginx and one domain), I've included the path for reference:
nginx.conf
#cat /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
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;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
server_names_hash_bucket_size 64;
server {
listen 80 default_server;
server_name "";
return 444;
}
}
* default_server is used to prevent access to nginx welcome page when accessing http:\serverIP . Behavior is not affected by returning this config to nginx default.
domain config
# cat /etc/nginx/sites-enabled/domain.tld.conf
server {
listen 80;
server_name domain.tld www.domain.tld;
location / {
root /var/www/domain.tld;
index index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# Setting log locations
access_log /var/log/nginx/domain.tld-access.log;
error_log /var/log/nginx/domain.tld-error.log debug;
}
I must mention that the purpose of this VPS is to learn basic Linux sysadmin, therefore there is no real data or restrictions and also that is my first contact with centos.
Thanks for your time and effort.
L.E. Adding "127.0.0.1 www.domain.tld domain.tld" to /etc/hosts does not fix the issue. Both domains are real domains with dns server and all records are replicated. Furthermore using trace-route to domain VPS IP is reached.
Nginx config is successful validated
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Upon further investigations I've noticed that no request appear in access or error log (error set to debug) when accessing domain.tld but they do for www.domain.tld Witch would send me straight to DNS but checking DNS using a few dig online versions everything seems OK, both domain.tld and www.domain.tld point to the correct VPS ip
Upvotes: 0
Views: 158
Reputation: 35
After loosing almost two days trying to figure out what is causing this issue finally, non-intentionally I've accessed the website while I was remote on another PC and to my utmost surprise everything worked just fine. Now I'm sure that I've cleared my DNS cache multiple times but apparently the issue was generated by plugin httpsEverywhere.
Thanks and I promise to try harder next time :D
Upvotes: 0