Linux - Cannot hide Apache version of vhosts - linux

I actually set up vhost with apache2 and i've a problem with the hardening of my vhost; the apache version and server OS is displayed in the header.
When i use the main server link, the version is hidden.
Help please.
Thanks.

You can hide the Server version like so:
ServerSignature Off
ServerTokens Prod
You will need to edit your .htaccess file or the main httpd.conf file.

use prod as server token
https://httpd.apache.org/docs/2.4/mod/core.html#servertokens
set server signature to off
https://httpd.apache.org/docs/2.4/mod/core.html#serversignature
hth

Related

How do I make apache2.4 configuration specific to a particular virtualhost so it doesn't affect other virtualhost on a centos server

I have put in my include file which is in this directory /etc/apache2/conf.d/userdata/std/2_4/myusername/sub.domain.com/proxy.conf.
On the file I did proxy reverse to localhost port 5000 for my net core app.
Then I did a post virtualhost include using include editor.
When I try to reach other domain on same VPS I get server temporarily unavailable to handle request error.but when I uncommented the proxy reverse on my include file i was able to reach other domain.
So my question is given the procedure I have taken, why is an include specified for a particular virtualhost affecting other virtualhosts on the server.
Proxy reverse code in the include file is code below
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/ ```
And this include was applied to virtualhost for the particular sub domain, don't know why it affects other virtualhosts.
Then I did a post virtualhost include using include editor.
If this means outside the <virtualhost> then its no wonder it affects all virtualhosts -- outside of <virtualhost> is global.
what i did was i opened up the post_virtualhost_global.conf file found in /etc/apache2/includes/.
then i removed the include statement from the post_virtualhost_global.conf file, then it worked, i dont seem to understand how, but it worked perfectly anyway. i have also applied same practice for subsequent virtualhost proxyreverse includes i have done afterward.

Apache configuration 2.4

I need to perform the following configuration on my Apache server, version 2.4, with CentOS system.
The instructions I received are as follows:
Configuring Another Web Server to Serve the Files If another web
server is using port 80 on the same server as Centova Cast, you will
need to use this method.
This method depends upon your knowledge of the other web server you
are using; you must be familiar enough with your web server of choice
to configure it appropriately. Centova Technologies cannot provide
support or assistance with any changes to your web server's
configuration.
To allow "Let's Encrypt" to validate your domain ownership, you must
configure your web server such that any requests for files under the
following URI (replacing example.com with your own domain name):
http://example.com/.well-known/acme-challenge/ ...are configured to
serve files from the following directory:
/usr/local/centovacast/etc/ssl/acme-challenges/ So for example, if you
create a file called
/usr/local/centovacast/etc/ssl/acme-challenges/test.txt, you should be
able to visit http://example.com/.well-known/acme-challenge/test.txt
in your browser and see the contents of the test.txt file.
A few example configurations are provided below. Please note, however,
that differences in your web server configuration may require
additional settings not mentioned here.
Example apache:
Alias /.well-known/acme-challenge /usr/local/centovacast/etc/ssl/acme-challenges
<Directory /usr/local/centovacast/etc/ssl/acme-challenges>
Options None
AllowOverride None
Apache 2.x
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
I've tried everything and I can't get it to work, how should the correct configuration be done?
My configuration file is located at: /etc/httpd/conf/httpd.conf

Apache on CentOS issue configuring routing to "Index.html" (uppercase"I")

I have a project being deployed such that an Apache instance is running on CentOS (DMZ) which is due to forward all requests to a TOMCAT instance running behind the firewall. For instance, a request:
www.Example.com
needs to be forwarded to:
HTTP://<servername behind the firewall>:<port number>/Blabla/Index.html
(Note that Index.html has a capital I).
I should note that the whole project required extensive review as it was developed under Windows (case insensitive filenames) but the running environment is Linux, and now all filenames and their references are fully synchronized.
The problem appears to be that it is not possible to configure within Apache to forward requests to Index.html and it converts it to index.html, which does not exist.
I can change all the file names to lowercase, but this will take quite some effort.
Is there any way to force Apache to use as-is what I define (i.e. if lowercase, use lowercase; if uppercase, use uppercase; if mixed, use mixed).
Thanks in advance.
You should be able to use mod_speling from Apache. In your configuration file, simply put:
CheckSpelling On
CheckCaseOnly On
And reload Apache using either:
/etc/init.d/httpd reload
Or if you're using CentOS 7:
systemctl reload httpd
This should now make all the files in your website directory insensitive.
If you're using virtualhosts, you may add this option into it:
DirectoryIndex Index.html
So your virtualhost should be like that :
<VirtualHost *:80>
ServerName website_name
DocumentRoot website_directory
DirectoryIndex Index.html
</VirtualHost>
You can paste it in /etc/httpd/conf.d/mywebsite.conf and reload apache with :
systemctl reload httpd
If you have CentOS/7. For older versions of CentOS use this command:
service httpd reload

Configure httpd.conf to add new site on Apache Red Hat Linux

I have linux server (Red Hat Enterprise Linux Server release 5.3 (Tikanga)) with apache installed. It is already used for browsing some documents. Now I would like to add a new Directory (with a html page), so whenever the directory is browsed it can display the html page.
But I am not sure of where all to edit the httpd.conf file
Existing httpd.conf:
When I hit the url "http://servername/eng" it displays list of folders.
Now, I want to add a website to this existing, so when user hit the url "http://servername/builds" it should display a html page in the browser.I have added my "index.html" page in location "/var/www/html/builds/"
For this I added the below code to httpd.conf file
Please let me know what all modifications are required in the conf file
You can do it in a few different ways.
Putting index.html in /build
This requires you to have this setting:
DirectoryIndex index.html
(it should be there by default on most platform.)
Also for this to work, rather than putting new <Directory>, you should put the build/ directory in the directory that holds your http://example.com/ files. For instance:
/var/www/example.com/public_html/eng/
/var/www/example.com/public_html/builds/
/var/www/example.com/public_html/builds/index.html
Storing build/ in folder completely unrelated to example.com, but still be able to reach it via example.com/builds
For this, you need to rewrite the URLs so that example.com/builds redirects the user to the final URL. This is most easily achieved through mod_rewrite. You enable mod_rewrite module in your Apache's configuration, make sure that example.com can have .htaccess files through ensuring proper AllowOverride entry in example.com's <Directory> configuration, create /var/www//example.com/public_html/.htaccess (or similar) file, and fill it RewriteEngine On and RewriteRules you need. More on mod_rewrite in the Internet and in the documentation.
Completely separate virtual server, for example builds.example.com/
In this case, what you're looking for are virtual servers. These are not defined in httpd.conf or configuration itself, but usually have dedicated directory.
For example, to add builds.example.com that works for port 80, you'd need to create following entry:
<VirtualHost *:80>
ServerName builds.example.com
DocumentRoot /var/www/builds.example.com/public_html/
</VirtualHost>
Where to put this? Well, it depends on the platform. For Debian, you put this in a new file in /etc/apache2/sites-available/, e.g. /etc/apache2/sites-available/example.com, and symlink to it in /etc/apache2/sites-available (on Debian, you can do this easily with a2ensite <NAME_OF_FILE>. On your platform this procedure might be different, so look it up ("adding virtual servers on " would be a start). After adding virtual servers, you need to reload your Apache configuration.
Please let me know if this satisfies your question, if not, I'll edit the answer accordingly.

PHP files are downloaded by browser instead of processed by apache2 after creating virtual hosts

I created a virtual host in apache2 (LAMP) as shown below and the php files are downloaded by the browser instead of processed by apache. I created an HTML file and it worked.
/var/www/myvirtualhost.com/public_html
ServerAdmin webmaster#localhost.com
DocumentRoot /var/www/myvirtualhost/public_html/
ServerName myvistualhost
Check this question out. It's for Apache on Ubuntu, and you don't specify what system you are on, but maybe you can get a tip from there.
Basically it describe how to install the PHP module for Apache, which is probably not installed if PHP-files are downloaded.

Resources