[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1951
  • Last Modified:

Problem setting up Apache, tomcat, SSL.(146) Connection refused.

Hi Experts,

I have successfully setting up my apache2 web server, http://www.domainname.com which is running jsp (tomcat5.0, jk2 connector).
Now, I need to set up my SSL at https://www.domainname.com.
What I have done is:
1) Create a local key pair using the following command:
openssl genrsa -dec3 -out domainname.com.key 1024
2) Create a self-signed certificate
openssl req -new -key domainname.key -x509 -out sslname.crt

3) Edit my httpd.conf
a) Enable my SSL
<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so

b) Configure my site
<IfDefine SSL>
ServerName      www.domainname.com
DocumentRoot    /www/tomcat5.0/webapps/sitename
DirectoryIndex  index.jsp
Errorlog        logs/sitename-error_log
TransferLog     logs/sitename-access_log
SSLEngine       on
SSLCertificateFile      /usr/local/ssl/bin/ssslname.crt
SSLCertificateKeyFile   /usr/local/ssl/bin/www.domainame.com.key
SetEnvIf User-Agent     ".*MSIE.*" nokeepalive ssl-unclean-shutdown

4) Reboot Apache

However, when I try to connect to https://www.domainname.com
The error message was (146) Connection refused.

My questions are:
1) Are my above configuration correct?
2) Do I have to do any setting in my tomcat server.xml?
If yes, what are the setting
3) Do I need to do any setting for the JK2 connector?
If yes, what are the setting.

Thank you very much

  • 5
  • 3
1 Solution
Add this line to your httpd.conf file:

Listen 443
totoronAuthor Commented:
Thanks. I have added the above line.

However I still encounter some problem.
I could see my web site at http://www.domainname.com:443
But I couldn't see any SSL secure sign at the bottom of my IE.

And I couldn't view it with https://www.domainname.com

Any solutions?

      <IfDefine SSL>
      LoadModule ssl_module modules/mod_ssl.so

just write:

      LoadModule ssl_module modules/mod_ssl.so

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Or if you need <IfDefine SSL>

then call apache with option: -D SSL
And some error log would be great why https://www.domainname.com isn't works...
totoronAuthor Commented:
Thanks. It works. if I specified it with -D SSL.
By the way. Is it possible to make that I just need the login page to enable the https ?
while the rest of the pages I don't need https
There are many solution, but if you need only one page to be server through ssl, then i thin best solution is check inside file.

PHP example:

Put this code at begining of your php file:

      if ( !isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on' ) {
         header ('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);

totoronAuthor Commented:
thanks a million

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now