LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-06-2022, 03:34 PM   #1
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Rep: Reputation: 22
Another Apache problem on CentOS 7


I have a working? apache setup.
Directory structure is:
/var/www/html
/var/www.webserver1
/var/www/webserver2

Both webserver1 and webserver2 work perfectly, but I'm trying to put a welcome /redirect page on html. I put an index.html page in /var/www/html but only get NOT FOUND

All the sites run on a subdomain of my main domain. Let's call it myDomain.com for the main domain and office.myDomain for all my subdomain sites.

I want /var/www/html to be a welcome and the server name to be office.myDomain.com

I can't get this to work. It must be something simple and silly, but I'm not a Linux guru. Used to be an eDirectory.NDS one though Linux makes eDir seem easy!

Last edited by baldur2630; 07-06-2022 at 03:36 PM.
 
Old 07-06-2022, 04:33 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
I am not sure I understand the arrangement.
What I envision is that office.mydomain.com is served from /var/www/html: server1.mydomain.com is served from /var/www/server1: and server2.mydomain.com is served from /var/www/server2.

If that is the case then anything placed in /var/www/html would only be seen in response to requests for office.mydomain.com, and similarly for the other 2 virtual server names.

It is possible to use symlinks so all would see the exact same page, but that would require a careful config to allow the web server(s) to use the symlinks and it would seem possibly counter to having each server display only the info for that domain.

There is much that can be done, but it would require careful consideration to serve suitable data for the particular domain of interest. Maybe even use a database with php, java, ruby, and/or css pages for formatting the proper content
 
Old 07-06-2022, 05:01 PM   #3
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by computersavvy View Post
I am not sure I understand the arrangement.
What I envision is that office.mydomain.com is served from /var/www/html: server1.mydomain.com is served from /var/www/server1: and server2.mydomain.com is served from /var/www/server2.

If that is the case then anything placed in /var/www/html would only be seen in response to requests for office.mydomain.com, and similarly for the other 2 virtual server names.
Exactly. Really simple. You type in your browser
office.myDomain.com and you get a Welcome page
server1.office.myDomain.com and you get a forum
server2.office.myDomain.com and you get a sales site

That's all I want. nothing complicated. plain and simple.
 
Old 07-06-2022, 05:14 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
I find your description to be very confusing. Rather than have those here make any assumptions, please try to rewrite your description a bit more clearly.

In particular, please associate each filesystem path explicitly with the URL (i.e. virtual host name) by which it is reached. For example:

Code:
Virtual Host                Filesystem Path
============                ===============
myDomain.com                /var/www/???
office.myDomain.com         /var/www/html
webserver1.myDomain.com     /var/www/webserver1
webserver2.myDomain.com     /var/www/webserver2
It would be reassuring if you could paste the relevant contents of your http-vhosts.conf file (or whatever your virtual hosts config file is named), suitably sanitized to hide actual domain names and addresses.

Then, please state explicitly the URL(s) which you want to result in the welcome index page being served.
 
Old 07-06-2022, 07:32 PM   #5
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
BTW, since the webserver is normally running as user apache on redhat based systems, it is necessary that all files in the /var/www/???? tree to have read and directories to have read/execute permissions for the apache user.

If files and directories do not allow access for the user under which the web server is running then it might be cause for what you are seeing. If selinux is in use then the proper context for selinux must also be set
 
Old 07-06-2022, 07:34 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,737

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
Besides configuring the web server, you’ll also need to have a DNS entry for server1.office.myDomain.com.
Where Is the NOT FOUND error from? The browser (a 404 error) or because the host can’t be found?
 
Old 07-07-2022, 01:23 AM   #7
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by astrogeek View Post
I find your description to be very confusing. Rather than have those here make any assumptions, please try to rewrite your description a bit more clearly.

In particular, please associate each filesystem path explicitly with the URL (i.e. virtual host name) by which it is reached. For example:

Code:
Virtual Host                Filesystem Path
============                ===============
myDomain.com                /var/www/???
office.myDomain.com         /var/www/html
webserver1.myDomain.com     /var/www/webserver1
webserver2.myDomain.com     /var/www/webserver2
It would be reassuring if you could paste the relevant contents of your http-vhosts.conf file (or whatever your virtual hosts config file is named), suitably sanitized to hide actual domain names and addresses.

Then, please state explicitly the URL(s) which you want to result in the welcome index page being served.
Code:
myDomain.com                 NOT on my server. Hosted by a Hosting company overseas
office.myDomain.com         /var/www/html
webserver1.myDomain.com     /var/www/webserver1
webserver2.myDomain.com     /var/www/webserver2
I have 3 of my own DNS servers. apart from myDomain, all three are on the DNS
webserver1.myDomain.com and webserver2.myDomain.com are online and work 100%

chown -R apache:apache /var/www
chmod -R 755 /var/www

Ports 80 and 443 are open on both firewalls.
SELinux DISABLED.
 
Old 07-08-2022, 05:20 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by baldur2630 View Post
Code:
myDomain.com                 NOT on my server. Hosted by a Hosting company overseas
office.myDomain.com         /var/www/html
webserver1.myDomain.com     /var/www/webserver1
webserver2.myDomain.com     /var/www/webserver2
I have 3 of my own DNS servers. apart from myDomain, all three are on the DNS
webserver1.myDomain.com and webserver2.myDomain.com are online and work 100%

chown -R apache:apache /var/www
chmod -R 755 /var/www

Ports 80 and 443 are open on both firewalls.
SELinux DISABLED.
That is progress of sorts, but raises as many questions as it answers.

It is helpful to know that these subdomains are to be served from a platform other than the main domain, but can you be a bit more specific - are they on a local machine, a VPS, perhaps another hosting account. Are they internet accessible? How are they reached, specifically? Geographic locations should not matter, it is network accessibility that matters.

You state...

Quote:
I have 3 of my own DNS servers. apart from myDomain, all three are on the DNS
webserver1.myDomain.com and webserver2.myDomain.com are online and work 100%
... but seem to avoid saying "office.myDomain.com is online and working". That is the one that you are trying to use for your welcome page, so that is a pretty important omission!

Please elaborate on what you mean by "work 100%" with regard to webserver{1,2}.myDomain.com. No one here can know how you reach them (i.e, from the same local machine? ... from an internal network? ... from anywhere on the internet?). Your case is more complex than your orignal description indicates - please fill in those blanks.

Similarly, it is good that you have three DNS servers, but without knowing anything about them that statement is really meaningless for troubleshooting purposes. What does a dig office.myDomain.com +noall +answer (or other DNS lookup) return for each of those subdomains, and from where? Do they all look to be correct, pointing to the right IP address, etc.?

You also mention "both firewalls", what specifically do you refer to by that statement? VPS firewalls? Local machine firewalls? Router firewalls? Help us help you!

To summarize what has been said so far in this thread:

* DNS lookup must be acessible and return a valid address for each subdomain - verify that.
* Virtual hosts must be configured and working for each subdomain on the target platform - verify that.
* Firewalls must allow access to the webserver on the target platform - verify that.

If you need help verifying any of that, please include all relevant details in your question, in particular the network topology, as that is still very obscure.

Last edited by astrogeek; 07-08-2022 at 05:29 PM.
 
Old 07-11-2022, 03:44 PM   #9
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 22
I've solved part of the problem. There are TWO firewall, the built-in one in CentOS 7 - firewalld. That was configures. SELinux disabled.
We have a new company firewall, OPNsense. It seemed to be working, we could access everything - but only from inside the firewall. Unti a customer informed us, we had no idea that traffic wasn't coming in from the WAN. It was a simple mustake and it has been fixed.

Currently we are only running ONE webserver, CentOS 7

The directory structure is
/var/www/html
/var/www/server1
/var/www.server2

Server1 and server2 both share the same IP but different names. both work perfectly. What I can't get to work is the /var/www/html.

I've been assuming that this isn't a virtual site and thus doesn't need a Virtual setup.

server1 and 2 are as follows:
<VirtualHost *:80>
ServerName server1.xxxx.mydomainFQDN
DocumentRoot /var/www/server1
RewriteEngine On
RewriteRule ^(/server1/.*) /www/server1$1

ServerAdmin mt email address
ServerAlias server1
ErrorLog /var/log/httpd/server1-error_log
TransferLog /var/log/httpd/server1-access_log
DirectoryIndex index.php
SERVER SSL CERTS ARE HERE.
</VirtualHost>

The Lets Encrypt SSL Certificates are also in here for each one.

All that I need is to get a simple welcome page to display when a user connects to the company website. Access to server1 and server 2 is by invitation only so Registered users know the URL they type to get in.

Once I can get a Welcome to <company> even it its a single line, to display, I can create a site on it. At present I am unable to get anything in the /var/www/html folder to work.

All have correct permissions for apache. All are on the DNS and server1 and server 2 work as wanted.

Does that make things clearer?
 
Old 07-12-2022, 02:53 PM   #10
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
How is your primary html config file written. That is the one that runs the main company web server and should access the /var/www/html directory as document root.

For my home PC running apache2 I have this in /etc/httpd/conf/httpd.conf for the main server. (mostly default)
Code:
ServerRoot "/etc/httpd"

Listen 80

Include conf.modules.d/*.conf

User apache
Group apache


ServerAdmin root@localhost

ServerName My.FQDN:80

<Directory />
    AllowOverride none
    Require all denied
</Directory>


DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks

    AllowOverride None

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>


    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>


    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz



    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>


EnableSendfile on

IncludeOptional conf.d/*.conf
This allows anyone to access my home page (index.html) which is located in /var/www/html.

It sounds to me like you have the virtual servers properly configured, but failed to properly configure the main server access

The very last line includes the files under /etc/httpd/conf.d/*.conf which is where each virtual server is configured in my system.

Last edited by computersavvy; 07-12-2022 at 03:16 PM.
 
1 members found this post helpful.
Old 07-13-2022, 03:54 AM   #11
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 22
Works great. Many thanks. but there is still a problem.

I have a main domain xxxxxxxx.com this is managed on a hosting site overseas.
I also have a sub-Domain. aaaa.xxxxxxxx.com and this is the one I'm referring to. This one is all i our offices. My two Virtual web servers (working) are Sefver1.aaaa.xxxxxx.com and server2.aaaaa.xxxxxxxx.com

I created a CName on our (in-house) DNS servers for aaaa.xxxxxx.com using www as the alias, so in THEORY, I should be able to go to http(s)://www.aaaa.xxxxxx.com but it doesn't work.

If I type http(s)://localhost on the CentOS server where the sites are hosted, I get the test page.

In your sample httpd.conf file, I put in the FQDN of my server as aaaa.xxxxxx.com:80

I seem to be missing something. Any idea what?

Last edited by baldur2630; 07-13-2022 at 04:57 AM.
 
  


Reply

Tags
apache



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SAMBA permissions on CentOS 6.5 - even root is being denied from another CentOS 7 workstation mike0000t Linux - Newbie 0 03-14-2016 09:44 AM
[SOLVED] Can I move an lvm hard drive to another machine? [CentOS 6.6 - CentOS 7] ohmster Linux - Hardware 2 05-17-2015 12:07 AM
[SOLVED] NFS on CentOS 6 can talk to Centos 5 but not Centos 6 clients deathsfriend99 Linux - Server 2 11-08-2013 02:33 PM
Load Balancing - ipvsadm with apache (mod_proxy) to another apache not working romeo_tango Linux - Server 1 01-12-2012 03:21 AM
CentOS in one VirtualBox, Windows in another - can I set up Samba in the CentOS VB? ismism Linux - Newbie 10 08-08-2010 03:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration