How does one change nagios default url to custom url? - nagios

I am running Nagios Core 4.0.8 in my environment and I am looking to find a way to change the default url from https://example.com/nagios to https://example.com. Is there a way one can do that?

You will need to edit the cgi.cfg file for Nagios.
vim /usr/local/nagios/etc/cgi.cfg
Change url_html_path=/nagios to url_html_path=/
Edit nagios.conf:
Change ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" to
ScriptAlias /cgi-bin "/usr/local/nagios/sbin"
Comment out the line Alias /nagios "/usr/local/nagios/share" and then add below
DocumentRoot /usr/local/nagios/share
Add the following at top of the configuration:
<VirtualHost *:80>
ServerName status.example.com
and add </VirtualHost> at the bottom.
Edit your /usr/local/nagios/share/config.inc.php file:
Change $cfg['cgi_base_url']='/nagios/cgi-bin'; to $cfg['cgi_base_url']='/cgi-bin';
Restart Apache and Nagios

If you are using Apache to serve your Nagios page you can do different things. Apache configuration files are usually located in /etc/apache2/.
Probably your DocumentRoot is set to /var/www, so you can create a file named "index.html" and place this code inside it to redirect to /nagios URL:
<META HTTP-EQUIV="Refresh" Content="0; URL=/nagios">
You can also edit your nagios apache config (probably /etc/nagios/apache2.conf...) or apache config /etc/apache2/*.conf and add:
RedirectMatch ^/$ /nagios
If you don't like these methods there are more, just think of it as using Apache to redirect, not like a Nagios thing.

Related

Enable server-side includes in Apache2 for selected domains

I'm running Apache2 (2.4.29-lubuntu4.11) on Ubuntu Server 18.04.
I see documentation for enabling server-side includes (SSI) when I google, but it's always done in httpd.conf (modern apache2.conf), etc. I suspect these are older posts. I manage my domains out of /etc/apache2/sites-available/some-domain.conf (individual vhost configuration) files and I don't wish to enable server-side includes except for a couple of domains.
Can the effect of enabling SSI be limited to only selected domains?
How is this done specifically? I've tried, for example,
<VirtualHost *:80>
...
AddType text/html .shtml
AddHandler server-parsed .shtml
AddOutputFilter INCLUDES .shtml
Options Includes
</VirtualHost>
How do Options, AddType, AddHandler, AddOutputFilter, etc., done in some-domain.conf, interact with what's in /etc/apache2/apache2.conf?
You can do it in your . htaccess as well as just enabling it in a container.
For more information please take a look at this documentation: https://httpd.apache.org/docs/current/howto/ssi.html
To permit SSI on your server, you must have the following directive
either in your httpd.conf file, or in a .htaccess file:
Options +Includes
This tells Apache that you want to permit files to
be parsed for SSI directives.
To enable SSI for a specific domain or directory you can also put it in a container inside a virtualhost configuration:
<Directory /example/dir>
...
Options ...someOtherOptions... +Includes
...
</Directory>
I think your last question (site conf or Apache conf) was already answered here.

Apache2 subsite url configuration

I have one main website and several subsites like :
/var/www/mainsite
/var/www/subsite0
/var/www/subsite1
/var/www/subsite2
...
/var/www/subsiten
With my actuel apache2 configuration, these url are available :
http://myip/mainsite
http://myip/subsite0
http://myip/subsite1
http://myip/subsite2
...
http://myip/subsiten
But I would like url path this :
http://myip/mainsite
http://myip/mainsite/subsite0
http://myip/mainsite/subsite1
http://myip/mainsite/subsite2
...
http://myip/mainsite/subsiten
Is it possible to get this result without change directories emplacement ? Only change the apache configuration ?
Thanks !
My apache version : 2.4.10
Yes, it is possible. You should make redirects in your apache2 virtualhost configuration (It depends what system you use) or simply in the web root directory's .htaccess file. For example:
#/var/www/.htaccess
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On
RewriteRule ^mainsite/subsite0/(.*)$ subsite0/$1 [L]
This will point all mainsite/subsite0/* request to the subsite0/*.
Make sure the apache2 mod_rewrite module is enabled. Again, the commands are depends on your system.
More info:
https://httpd.apache.org/docs/2.2/howto/htaccess.html
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Apache localhost authentication

I am trying to setup up basic authentication to a folder on my localhost running apache. Currently the app runs fine without authentication. I have setup a virtual host so I can access my application through dev.myapp.com
The code I add to my .htaccess file to force authentication is:
<Directory "/Users/myusername/Sites/dev.myapp.com">
AuthType Basic
AuthName Test
AuthBasicProvider file
AuthUserFile /etc/apache_users
Require valid-user
</Directory>
I have created a user.
When I type dev.myapp.com into the browser I get an internal server error. I am fairly new to apache. A point in the right direction would be appreciated.
Thanks.
First off, using .htaccess is a bit slower and requires that you have set the AllowOverride directive accordingly. It is recommended that you instead use httpd.conf to establish basic authentication. The Apache documentation explains all of this so check out this link http://httpd.apache.org/docs/2.2/howto/auth.html.
Regardless, I think I see the error. Your <Directory> tag looks a little odd. I understand the name of your site is dev.my.app.com but is that the actual name of the folder where the site dev.myapp.com points to on your server? Your httpd.conf file should have an entry like this:
<VirtualHost *>
DocumentRoot "document/root/path"
Other directives here
</VirtualHost>
The DocumentRoot is where Apache directs all incoming web traffic. If you are trying to establish authentication for your entire site, the value of DocumentRoot is most likely what you would want in your Directory tag ... making it <Directory /document/root/path>.
To locate httpd.conf look in in /etc/apache2/. Make sure to restart your server after you change the file (sudo /etc/init.d/apache2 restart). Hope that helps, please update if you haven't already resolved the problem.

cakephp URL get rid of /app/webroot

I have a application and I want to integrated it into my CakePhp website. I put it into webroot folder. I tried to open it in browser via
http//mywebsite.com/appname
but it failed. Instead, I need to reach it via
http//mywebsite.com/app/webroot/appname.
And will be redirect to
http//mywebsite.com/app/webroot/appname/index.
Anyone know how to get rid of the /app/webroot string in my url? I do check the cake routing documentation but feels like didn't found a solution there.
Your Apache virtual host is not configured right.
Your Document Root needs to point to the webroot dir:
<VirtualHost *:80>
DocumentRoot /mydir/somthing/cake/app/webroot
ServerName mywebsite.com
</VirtualHost>
Then this will work:
http//mywebsite.com/appname

How to install cakephp on localhost?

I wanna to know how to install cakephp on localhost?
Please explain me.
I usually make an apache and mysql installation on a linuxbox. I can use windows too, however I do not recommend it ;)
So, I usually make a new entry into the /etc/hosts file to make a sitename available to cakephp.
127.0.0.1 localhost caketest.local
next step to copy all cakephp files into a subdirectory inside /home/myusername/public_html/caketest
app
cake
index.php
plugins
README
vendors
.htaccess
then I set up the site to apache (not neccessary),
<VirtualHost *:80>
DocumentRoot "/home/myusername/public_html/caketest"
ServerName caketest.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/home/myusername/public_html/caketest">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restart apache. you also need to edit the .htaccess files and place a RewriteBase directive with hte path to the actual directory, e.g.
RewriteBase /~myusername/caketest
create a database, set the db connection in cake config files and that's all.
you can point your browser to http://caketest.local
if you do not want a test site url you can skip hosts, and apache vhost creation, but the url to use should be http:/localhost/~myusername/caketest
another important thing is to enable userdir modul in apache, and also check if using php is enabled in userdirs too.
If you're on windows, get WAMP. Install it, then download CakePHP in C:\wamp\www\. Extract CakePHP in that folder so you have a folder kind of like this: C:\wamp\www\cakephp\. Now you can access the installation by going to localhost/cakephp/.
An old article of mine but still quite relevant:
Installing CakePHP
Assuming you have a *AMP setup (Apache+MySQL+PHP), just copy the files to your htdocs folder. On Ubuntu, it's /var/www, so you would create /var/www/myApp and copy the whole Cake structure into there, ending up with something like:
/var/www/myApp/app/
/var/www/myApp/cake/
/var/www/myApp/vendors/
/var/www/myApp/index.php
/var/www/myApp/.htaccess
Then you can access your app by the url: http://localhost/myApp

Resources