Nagios web interface access without slash at localhost - linux

How can I access the Nagios web interface without using the slash on a local host?
For example, when typing the IP address i need to access nagios. In other words, I don't want to use the slash, as follows: 192.168.123.122/nagios

I think what you're looking for is a base URL redirect match within Apache.
With that, going to http://192.168.123.122 will redirect you to http://192.168.123.122/nagios
In the file:
/etc/apache/apache2.conf
Add the following lines
<Directory />
Options FollowSymLinks
AllowOverride None
RedirectMatch ^/$ /nagios
</Directory>
Restart Apache and you should be good to go.

Related

mod_rewrite is enabled, .htaccess file is ok, but requests are not going through index.php

I've just installed ubuntu-server_6.04.2_LTS, after the fresh installation I've enabled mod_rewrite, it's showing in phpinfo()
my .htaccess file is OK
but, still requests are not going through index.php
You should check if for that specific directory (root folder of your project), apache is configured to allow overriding through .htaccess.
If you want to allow such override, the directives found in apache.conf or the specific settings for your virtual host should look like this:
<Directory /var/www/>
AllowOverride All
Require all granted
</Directory>

Redirect all requests to base URL without using .htaccess

When I browse example.com/img it shows all the directory contents. This leads to security problem . How to redirect these kind of url requests to example.com but without using htaccess
Best practice usually suggests adding these lines to your Apache config to disable directory listing:
<Directory />
Options -Indexes
Order allow,deny
Allow from all
</Directory>
But this will simply deny users access to the URL example.com/img. If you'd like to redirect as well, you could add an index.php file to each directory you'd like to redirect from in addition to making the Apache config change. The index.php file should contain:
<?php
header("Location:".$_SERVER['DOCUMENT_ROOT']);

.htcaccess in Apache not working

I enabled mod_rewrite and want to redirect one of my local virtual host websites to google.com for practice.
I created an .htcaccess file in my virtual directory (/var/www/example.com/.htcaccess) and gave permissions to .htcaccess by adding the following code to my virtual host's (example.com) config in /sites-available/.
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I am now attempting to use mod_rewrite by adding code to the .htcaccess file but have had no success thus far. Is there any way to check if .htcaccess is working? If it is, how do I redirect using mod_rewrite?
There is an typo. Normally the file name is .htaccess, not .htcaccess.
An other option is to set the file-name to you "personal style", like:
AccessFileName .htcaccess
http://httpd.apache.org/docs/2.2/howto/htaccess.html

apache2 rewrite rules not working

I am trying to write some rewrite rules in apache2 conf and they are not working
Following is my virtualhost block in apache conf. My os is ubuntu 12.04 server edition
DocumentRoot /var/www/xyz
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/xyz>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
AllowOverride All
Order allow,deny
#Order deny,allow
allow from all
</Directory>
I have .htaccess file with some rewrite rules as follows
ReWriteEngine on
RewriteRule ^/matchV/(.*) http://host:8080/$1
RewriteRule ^/other/(.*?)$ /httpdcontent/$1
rewrite module is enabled with apache.
Can someone tell me if i am missing anything.
Thanks,
Sandeep
First of all, a dollar sign seems to be missing on the first rewriting rule.
Then, I would recommend the use of [L] in "debug" situation. This way, only one rule would have to be corrected at the time.
If you need to check how the rewriting goes, you need to have a look at your log files /var/log/apache2/error.log and /var/log/apache2/access.log. They will tell you what URL the server tried to process, and how it failed. From this, you should be able to see what is missing, or what is "too much".
From what I see, I would say it has to do with the rewriting base. Your webserver root is probably at /var/www, and the directory for the virtual host is /var/www/xyz. I think you could fix it using something like...
RewriteBase /xyz
Anyway, edit the configurations, and don't stop checking the logs. From there, you'll see what URL/File the server tries to process, and you should be able to correct the paths it uses.

Protect restrict Solr Admin url from external user using .htaccess or tomcat

I have recently installed Solr on server and i want to restrict only local users can access it with .htaccess
site.com:8983/solr/admin [ restrict all user]
And below is the .htaccess code
RewirteRule on
<FilesMatch "127.0.0.1:8983/solr/admin">
Order Deny, Allow
Deny form all
Allow 127.0.0.1
</FilesMatch>
Or is there any method we can protect / restrict Solr Admin on site.com:8983/solr/admin accessing from other users
Only local ip users can use it..
And i tried this one, but its not working.
Your <FilesMatch "127.0.0.1:8983/solr/admin"> line will never match anything because you've stuck the hostname and port in the regular expression. Try using the Location container instead:
<Location "/solr/admin">
Order Deny, Allow
Deny from all
Allow 127.0.0.1
</Location>
Or better yet, Directory:
<Directory "/path/to/your/document/root/solr/admin">
Order Deny, Allow
Deny from all
Allow 127.0.0.1
</Directory>
You'll need to fill in the full path to the solr/admin directory.
Get rid of the RewirteRule on line, it doesn't do anything and it's not even spelled right and will cause a 500 error.
However, neither of these directives can be use in an htaccess file. You need to use these in either the server of vhost config. If you must use an htaccess file, then create an htaccess file in your solr/admin directory and simply put these directives in it:
Order Deny, Allow
Deny from all
Allow 127.0.0.1
Or, in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteRule ^/?solr/admin - [L,F]
Check following links. Hope they will help you.
Restrict Solr Admin Access
Solr Security
Securing Solr administrative console
How to protect Apache Solr admin console

Resources