Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Apache + Tomcat Servlet port question

Options
  • 29-07-2007 11:20pm
    #1
    Registered Users Posts: 495 ✭✭


    I've been developing a servlet to run on tomcat + apache. At the moment I'm accessing it using the normal http://localhost:8080/servlet/ URL
    Is there a way of configuring apache so that I can access it using the URL http://localhost/servlet/ ?

    Been searching on google, and the only option I can find is to change tomcat so that it listens on port 80, but I'd prefer not to do this, I want to keep apache as the web server


Comments

  • Closed Accounts Posts: 333 ✭✭McGintyMcGoo


    It begs the question "Why?".

    As far as I know, you need to keep apache and tomcat operating on different ports but I dont understand the problem of leaving tomcat on 8080. Is it a case that you dont want people having to type in the ":8080" part? Surely that can be controlled within your website application.


  • Registered Users Posts: 495 ✭✭tetsujin1979


    Is it a case that you dont want people having to type in the ":8080" part? Surely that can be controlled within your website application.
    Yeah, that's pretty much it, and I don't know how to do it.


  • Registered Users Posts: 240 ✭✭saltie


    Try creating index.html file in <CATALINA_HOME>/webapps/ROOT

    Use the following code

    <html>
    <head>
    <title></title>
    <META HTTP-EQUIV="refresh" CONTENT="0;URL=:8080/<URL>">
    </head>
    <body>
    </body>
    </html>

    and restart


  • Registered Users Posts: 495 ✭✭tetsujin1979


    Thanks saltie, but unfortunately that applies to all pages on the server, and I only want it applied to servlets, so I can still enter http://localhost/mypage.html and not have mypage.html on the tomcat server

    I've found this article on mod_jk2: http://rimuhosting.com/mod_jk2.jsp
    Has anyone used it and do you think it would serve my purposes?


  • Registered Users Posts: 7,541 ✭✭✭irlrobins


    I've config'd apache and tomcat using jk2 and it worked well. Just don't ask me how I did it as it's been a few years since I did it!

    But reading thru that link it looks like the steps I had to do to get it working. I didn't find it particulary difficult to setup and I think I found all the info with a quick google.


  • Advertisement
  • Registered Users Posts: 378 ✭✭sicruise


    I'm gonna loose the plot... i was logged out by the time i finished writing the bleeding thing and didn't copy it...

    grr... i spent 20 mins writing it...

    basically don't get version 2 get version 1.2.23

    you need to load the module into apache... create a workers.properties file



    Add this to your virtual host
    JkMount /* defeault

    where default is the name of your worker...

    sorry i wrote an entire guide n i'm so peeved now... has boards reduced session timeout or something? and why after i sign in does it not continue with adding the post??


  • Registered Users Posts: 7,541 ✭✭✭irlrobins


    I got it working on Apache 2 no bothers, so don't be afraid to go with that. Is 1.3 still supported?


  • Registered Users Posts: 3,886 ✭✭✭cgarvey


    mod_jk has disadvantages that you'd want to read up on before using that in production. If it's just for dev/testing, then it's pretty easy to set up.

    For production use, more people seem to be turning to mod_proxy and mod_rewrite these days (from mod_jk / jk2). You can easily rewrite requests to /servlets/* or *.jsp or whatever suits your install then. It can also scale if you have 2 or more Tomcat machines behind Apache httpd (including support for sticky sessions).


  • Registered Users Posts: 378 ✭✭sicruise


    irlrobins wrote:
    I got it working on Apache 2 no bothers, so don't be afraid to go with that. Is 1.3 still supported?

    Version 2 of mod_jk is no longer supported...

    Basically if you have apache and tomcat on seperate servers then you will run into loads of issues... not worth the bother.

    BTW... cgarvey... mod_jk supports everything you just pointed out there...


  • Closed Accounts Posts: 161 ✭✭nude_hamster


    I've been developing a servlet to run on tomcat + apache. At the moment I'm accessing it using the normal http://localhost:8080/servlet/ URL
    Is there a way of configuring apache so that I can access it using the URL http://localhost/servlet/ ?

    Been searching on google, and the only option I can find is to change tomcat so that it listens on port 80, but I'd prefer not to do this, I want to keep apache as the web server

    modJK will do this with apache2.x and apache1.3, I have done alot of work with this and it works pretty well, Let apache deal with all the redirects, SSL certificates and encryption, and then tomcat can take over to dish out the web app. you can get tomcat to run directly on port 80, and not have apache at all...but tomcat doesnt make a very good public server. On any linux or unix distro, I have a short walkthrough written up here:
    tomcat.doc

    (if you use the walkthrough could you let me know what you think, nobody have used it before :) )
    As for on windows ...i dont know exactly how to go about setting it up.


  • Advertisement
  • Registered Users Posts: 7,541 ✭✭✭irlrobins


    sicruise wrote:
    Version 2 of mod_jk is no longer supported...
    Apologies I misread your post. I thought you were refering to Apache2 and Apache1.3.

    Ignore me. Carry on....


  • Registered Users Posts: 495 ✭✭tetsujin1979


    modJK will do this with apache2.x and apache1.3, I have done alot of work with this and it works pretty well, Let apache deal with all the redirects, SSL certificates and encryption, and then tomcat can take over to dish out the web app. you can get tomcat to run directly on port 80, and not have apache at all...but tomcat doesnt make a very good public server. On any linux or unix distro, I have a short walkthrough written up here:
    tomcat.doc

    (if you use the walkthrough could you let me know what you think, nobody have used it before :) )
    As for on windows ...i dont know exactly how to go about setting it up.

    The setup on windows is fairly straightforward, download the correct version for your apache version here: http://ftp.wayne.edu/apache/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.23/
    You need to rename the file to mod_jk.so

    The walkthrough was fine, but I needed to make 2 changes:
    LoadModule <apache2 directory>/modules/mod_jk.so -> LoadModule jk_module modules/mod_jk.so
    JkMount /service /* server1 -> JkMount /service/* server1

    Other than that it works fine
    Thanks for all responses and help, got there in the end!


  • Closed Accounts Posts: 161 ✭✭nude_hamster


    ahh ok ...sorry :) obviously lefts a good few things out


Advertisement