Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm running a server with CentOS 8 and Apache 2.37 for hosting a wordpress site. That website should replace an old one, with the same domain name.
I edited inside and outside dns servers (bind) and added the ip address of a new server.
On the server itself, the /etc/hosts:
.
.
.
192.1.1.1 somesite.com
and I have changed only a few things in the default configuration files: /etc/httpd/conf/httpd.conf
Code:
#
ServerName somesite.com
#
...
#
DocumentRoot "/var/www/html"
#
# Further relax access to the default document root:
<Directory "/var/www/html">
#
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
and added digital certificates in /etc/httpd/conf.d/ssl.conf
Code:
<VirtualHost _default_:443>
# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"
#ServerName www.example.com:443
# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# List the protocol versions which clients are allowed to connect with.
# The OpenSSL system profile is used by default. See
# update-crypto-policies(8) for more details.
#SSLProtocol all -SSLv3
#SSLProxyProtocol all -SSLv3
# parallel.
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/pki/tls/certs/somesite.com.crt
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
# ECC keys, when in use, can also be configured in parallel
#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/pki/tls/private/somesite.com.key
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convenience.
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt
...
I don't have a virtual host, so I dont have a /etc/httpd/conf.d/somesite.conf file as I normally do.
The problem is:
When I type somesite.com in my webbrowser i get the site that I want but instead of domain name I see:
192.1.1.1
(and it shows no certificate, probably because it's ip address instead of somesite.com)
Apache configtest is ok and dns records are all ok.
What could be the issue? Could it be dns - more than 24h have passed and I do get the site, just not the address.
I have no idea what to try...
Can somebody help me?
Thanks!
Kind regards.
Last edited by sirius_lee; 02-23-2022 at 12:09 AM.
The problem is:
When I type somesite.com in my webbrowser i get the site that I want but instead of domain name I see:
172.16.1.202
You can run the following command to see what vhosts are defined in your apache configuration:
Code:
apachectl -S
Re. the SSL vhost:
Quote:
<VirtualHost _default_:443>
# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"
#ServerName www.example.com:443
<snip>
You should use a DocumentRoot and a ServerName also in the SSL vhost and ditch the _default_ keyword in the vhost definition:
Code:
<VirtualHost *:443>
# General setup for the virtual host, inherited from global configuration
DocumentRoot "/var/www/html"
ServerName somesite.com
<snip>
You can run the following command to see what vhosts are defined in your apache configuration:
Code:
apachectl -S
Re. the SSL vhost:
You should use a DocumentRoot and a ServerName also in the SSL vhost and ditch the _default_ keyword in the vhost definition:
Code:
<VirtualHost *:443>
# General setup for the virtual host, inherited from global configuration
DocumentRoot "/var/www/html"
ServerName somesite.com
<snip>
In a moment of total desperation I've added a somesite.com.conf file with this configuration:
This is what apachectl -S gives me back (thank you for the command btw):
VirtualHost configuration:
*:80 somesite.com (/etc/httpd/conf.d/somesite.com.conf:10)
*:443 is a NameVirtualHost
default server somesite.com (/etc/httpd/conf.d/somesite.com.conf:1)
port 443 namevhost somesite.com (/etc/httpd/conf.d/somesite.com.conf:1)
alias www.somesite.com
port 443 namevhost 127.0.0.1 (/etc/httpd/conf.d/ss
<snip>
So apachectl reports the correct vhosts
Did you restart apache after making the changes?
Also make sure that you clear your browser cache or use a different browser, before testing
Re. the .htaccess, it's ok.
It's the default .htacces for wordpress, but it's content is duplicated in your case!
So apachectl reports the correct vhosts
Did you restart apache after making the changes?
Also make sure that you clear your browser cache or use a different browser, before testing
Re. the .htaccess, it's ok.
It's the default .htacces for wordpress, but it's content is duplicated in your case!
Of course, I've restarted it, maybe even a few times.
Sometimes, the site is still unreachable from different browsers and maybe from a phone etc, so I guess it's still dns propagation, but even when it works it's always ip address.
I've also seen this: https://serverpilot.io/docs/solution...ead-of-domain/ but the developer says that it fills automatically if everything is set correct. I've recently put up a server with similar configuration on centos 7, and it works as expected
and here I don't know where to check anymore.
If the dns zone and the main domain is somesite.com could it be a problem if the site has the same name?
I don't use apache, I use nginx. But the principles are the same. My observations:
server_name is not required for this to work
your http => https redirection might be wonky. Can you try a web browser that does not automatically redirect? E.g. dillo.
Excerpt from my default config:
Code:
server {
listen 80;
listen [::]:80;
#### PERMANENT REDIRECT BEGIN ####
#server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
#### PERMANENT REDIRECT END ####
listen 443 ssl;
listen [::]:443 ssl;
include ssl.conf;
#server_name example.com;
index index.html index.php;
<snip>
Even if I comment that line out, it still doesn't work. Now, I cannot even reach it from the outside network.
Ping works, nslookup shows the right address but I get nothing for www.somesite.com:
Even if I comment that line out, it still doesn't work. Now, I cannot even reach it from the outside network.
Ping works, nslookup shows the right address but I get nothing for www.somesite.com:
1. You should add in the dns an A RR pointing to the IP of your webserver
2. You should add the following in both http and https vhosts:
Code:
ServerAlias www.somesite.com
BTW the Redirect from the non SSL to the SSL enabled vhost is correct.
You can add also the "Permanent" keyword like this:
Code:
Redirect permanent / https://somesite.com/
1. In my internal dns it goes:
somesite.com 192.1.1.1 - > internal ip
in both master and slave.
In my external dns
somesite.com 1.1.1.1 - > outside ip, in both master and slave.
Is it possible that the name of the domain cannot be the same as the website?
There are many entries in the dns that go like this:
Site1.somesite.com ip
site2.somesite.com ip
...
site50.somesite.com ip
But the main site should be somesite.com ip
Is there a naming problem? I don't think that should be an issue...
2. There are aliases in both, yes, but the site cannot be open outside of my network, just internally and it always shows ip address.
I'm seriously considering that this might be the wordpress problem, because it was apparently installed with ip address.
The ping works for both external ip and the site name, also nslookup shows correct outside address and tracert shows unreachable after couple of hops but then resumes to the correct address.
1. In my internal dns it goes:
somesite.com 192.1.1.1 - > internal ip
in both master and slave.
In my external dns
somesite.com 1.1.1.1 - > outside ip, in both master and slave.
Is it possible that the name of the domain cannot be the same as the website?
There are many entries in the dns that go like this:
Site1.somesite.com ip
site2.somesite.com ip
...
site50.somesite.com ip
But the main site should be somesite.com ip
Is there a naming problem? I don't think that should be an issue...
From the dns perspective just make sure that www.somesite.com resolves to the same IP as the plain somesite.com
Quote:
2. There are aliases in both, yes, but the site cannot be open outside of my network, just internally and it always shows ip address.
I'm seriously considering that this might be the wordpress problem, because it was apparently installed with ip address.
The ServerAlias is not going to work if there is no entry for www.somesite.com in the dns.
Showing the IP address instead of the hostname, it could be the wordpress problem you mentioned in your #5 post above.
Did you follow the instructions there to see if it solves that issue?
From the dns perspective just make sure that www.somesite.com resolves to the same IP as the plain somesite.com
The ServerAlias is not going to work if there is no entry for www.somesite.com in the dns.
Showing the IP address instead of the hostname, it could be the wordpress problem you mentioned in your #5 post above.
Did you follow the instructions there to see if it solves that issue?
I put www.somesite.com as an alias of somesite.com, I hope that's going to work.
It doesn't yet, but maybe it will.
As for wordpress, I've just contacted the developer, let's see if he is willing to do something.
Thank you for staying with me, this is a nightmare.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.