Showing posts with label httpd. Show all posts
Showing posts with label httpd. Show all posts

Monday, December 17, 2012

How we can provide custom authentication for apache webserver

How we can achive ?
Create authen.txt with the username and password separated by colon
authen.txt
sampleuser : sampleuser
Then use the htpasswd to encrypt the password
Apache2\bin>htpasswd.exe -b authen.txt  sampleuser sampleuser 
Automatically using MD5 format.
Updating password for user testuser
Add the following in the httpd.conf file present in C:\Program Files\Apache Group\Apache2\bin
LoadModule weblogic_module modules/mod_wl128_20.so
<Location />
SetHandler weblogic-handler
WebLogicHost localhost
WebLogicPort 7001
Debug ALL
WLLogFile c:/Saple/wlproxy.log
WLTempDir c:/Saple
AuthUserFile C:/Saple/ authen.txt
AuthName “This is a protected area” 
AuthType Basic 
Require valid-user
</Location>
Also copy WL_HOME\server\plugin\win\32\mod_wl_22.so to C:\Program Files\Apache Group\Apache2\modules
Restart the Apache Server.
Now if we try to access any unprotected resource on Weblogic Server, a BASIC Authentication Window will be popped up for authentication against Apache.
If authentication is successful, the request will go through provided we set the following in the config.xml
<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>
Otherwise Weblogic Server will try to validate the BASIC authentication Header.

Configuring two way SSL between Client and Weblogic server with Apache proxying the request.


Configure Apache for SSL
Create the certificates using openssl (present in apache_home\bin) using the below steps:
openssl genrsa -des3 -out server.key 1024
openssl req -config ..\conf\openssl.cnf -new -key server.key -out localhost
openssl x509 -req -days 730 -in localhost -signkey server.key -out server.crt
Add the following in the httpd.conf file
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Listen 443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile “C:\Program Files\Apache Group\Apache2\conf\server.crt”
SSLCertificateKeyFile “C:\Program Files\Apache Group\Apache2\conf\server.key”
SSLCACertificateFile “C:\Documents and Settings\Administrator\Desktop\cert\IntermediateCA.cer”
#SSLLog “C:\Program Files\Apache Group\Apache2\conf\ssl.log”
#SSLLogLevel debug
</VirtualHost>
Configure SSL between Apache and Weblogic Server
Add the following in the Location Directive
SecureProxy ON
TrustedCAFile C:\bea101\wlserver_10.0\server\lib\CertGenCA.pem
RequireSSLHostMatch false
Configure Apache to Request for Client Certificate
Add the following in the Location Directive
SSLVerifyClient optional_no_ca
SSLOptions +ExportCertData
Configure Weblogic Server for 2-way SSL
mydomain> Servers> myserver>Keystores & SSL > Advanced Options
Hostname Verification: None
Two Way Client Cert Behavior: Client Certs Requested but not enforced
Apache_SSL> Domain Wide Security Settings> Realms> myrealm> Authentication Providers> DefaultIdentityAsserter
Trusted Client Principals: provide CN of the Client Certificate
Types: X509
Details:
Use Default User Name Mapper: Checked
Default User Name Mapper Attribute Type: CN
Base64Decoding Required: Checked
Go the security realm and create a user wih the username as CN of the certificate
Add the following in the config.xml
<Server ClientCertProxyEnabled=”true”
Configure the Web Application
The Web Application should require client cert authentication.
Add the following in the web.xml
<context-param>
<param-name>weblogic.httpd.clientCertProxy</param-name>
<param-value>true</param-value>
</context-param>
Add the following in the weblogic.xml
<principal-name> CN of the certificate</principal-name>

Common Error With Apache 2.4 on Windows 7 64 bit


Common Error With Apache 2.4

I was trying to install Apache Http Server 2.4 on Windows 7 64 bit and was receiving error while starting the Apache Server :

AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using XXXX::XXXX:XXXX:XXXX.
Set the 'ServerName' directive globally to suppress this message

Root Cause :

Apache Server is looking for the hostname name which it can use to start and listen for request. If there is a hostname configured on the machine and it is not configured in the httpd.conf file then it will throw this error .

Solution:

  • Get the hostname of the machine on which the Apache Server is installed using the OS command : hostname
  • Configure the same in the httpd.conf file with the directive : ServerName as shown below:
ServerName Sandeep
  • Restart the Apache Server.
In case you do not want to use the Machine Hostname with the Apache Server then make the ServerName Entry in the httpd.conf file as localhost.

Apache webserver install on Linux


Apache Webserver install on linux ( Httpd )

APACHE – WEBSERVER

The Apache HTTP Server, commonly referred to as Apache is web serversoftware notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million web site milestone. The majority of web servers using Apache run a Linux operating system.

Apache is primarily used to serve both static content and dynamic Web pages on the World Wide Web. Many web applications are designed expecting the environment and features that Apache provides.

Current Apache webserver : APACHE 2.2.14 / Release on : October 5, 2009

APACHE Httpd installation on Solaris :

1. Download the file httpd-2.2.14.tar.gz from the link :http://httpd.apache.org/

2. Unzip using command gzip –d httpd-2.2.14.tar.gz

3. UnTar the Existing file using the command tar -xvf httpd-2.2.14.tar

4. After untaring you have to go to the httpd folder cd httpd-2.2.14

5. Configure by using command which enables all the proxy modules
./configure –prefix=/opt/apache22 –enable-proxy –enable-proxy-ajp –enable-proxy-balancer –enable-proxy-http

6. If you get a gcc and make not found error, then find whether GCC is available or not by typing
echo gcc or gcc –v
echo make

if you did not find the gcc then go to the root and find the path for gcc using below command

find . -name gcc and find . –name make

after finding the path get back to httpd-2.2.14 dir and add the path,

for gcc export PATH=$PATH:/usr/sfw/bin
for make export PATH=$PATH:/usr/ccs/bin

and now you can configure
After configuring type the command make

7. After make the type the command make install

8. Installation is completed. Now operate the apache . To start the apache go to the bin folder cd /opt/apache22/bin
Type ./apachectl start (stop/restart)

If you have the problem with the ports then change the port numbers in httpd.conf file, after changing the port restart the apache

Most of us had a general error ” server not found”.
To fix this open main configuration file with vi editor and un comment the line “server name pc name com:80″

Now try again and restart the apache.
Now goto webbrowser and type http://localhost/ If the page displays IT WORKS then the apache is working perfectly.

Mod_jk connector to connect Webserver & Appserver


Mod_Jk Connector to connect web server(Apache) to application server (Tomcat)
Mod_jk is used to connect apache webserver with tomcat application server

Download the mod_jk connector from

Extract the file using below command
tar -xzvf apache-tomcat-6.0.18.tar.gz

Add the path of apxs to the env $PATH by
export PATH=$PATH:/home/subha/apps/webserver/httpd-2.2.11/bin/apxs

Go to this folder
cd tomcat-connectors-1.2.27-src/native
./configure  –with-apxs=/home/subha/apps/webserver/httpd-2.2.11/bin/apxs
make
make install (assuming the user is root)

Copy the file mod_jk.so to httpd-2.2.11/modules/ (if not already present)
-   vi /httpd-2.2.11/conf/workers.properties

Paste the following output into the file:
.tomcat_home=/home/subha/apps/appserver/apache-tomcat-6.0.18
workers.java_home=/usr/bin/java
ps=/
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=worker1

-   vi httpd.conf
-   Append the following to httpd.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /home/subha/apps/webserver/httpd-2.2.11/conf/workers.properties
JkLogFile /home/subha/apps/appserver/apache-tomcat- 6.0.18/logs/mod_jk.log
JkLogLevel debug
JkMount /sample/* worker1
JkMount /sample1/* worker1
JkMount /servlet/* worker1
JkMount /*.jsp worker1
-   Test by http://localhost/sample/