I've been trying to find a solution to what I think should be a very common use of Alias with Tomcat & Apache Httpd but I can't find it.
I have Tomcat running my application server and I want to be able to use aliases to serve dynamic content. I configured Apache Httpd as the front end with Mod_JK to serve all dynamic files via Tomcat. This works fine except when using aliases as Tomcat doesn't know how to handle the Alias.
Basically I have my Tomcat application /webapps/myApp inside that I have "/folderA" so using http:localhost:8080/myApp/folderA works fine as well as localhost/myApp/folderA. I want to be able to user /folderB to point to /folderA and serve dynamic content and that's when things fail.
I have everything working well with mod_jk and the alias requests get redirected to Tomcat, however Tomcat does not know what to do with the alias so it tries to find /webapps/myApp/folderB which doesn't exists so I get a "file not found" error.
I tried using a <Context path... but then I get served static content. I also tried using Apache RewriteRule to pass requests from /folderB to /folderA but that doesn't work either. Below is an example of the VirtualHost settings I have. I'm guessing I need to do something in Tomcat's end so that it knows how to handle /folderB and point it to /folderA OR to make httpd translate /folderB to /folderA before passing the info to Tomcat.
Any help is appreciated. Thanks!
<VirtualHost *:80>
DocumentRoot "/webapps/ROOT"
Alias /folderB "webapps/ROOT/folderA"
JkMount /folderB/* myWorker
ServerName myServer.local
ServerAlias www.myServer.local
ErrorLog "logs/myServer.local-error.log"
</VirtualHost>
Really late, but I have the same problem and here is a working solution: The Alias within the VirtualHost is ignored for all files handled by the mod_jk.
Update your tomcat/conf/server.xml and add a Context to your Host:
<Host name="your-domain.com" appBase="webapps">
<!-- root path -->
<Context path="" docBase="/your/app/" />
<!-- alias for folderB -->
<Context path="/folderB" docBase="/your/app/somewhere/else/folderb/" />
</Host>
This really confuses me, because ColdFusion and the Connector know the Apache Aliases. I will update my answer if I have any progress..
Related
I'm having troubles setting up a moodle instance behind an apache proxy.
Here's my apache front-end that proxies to the running server.
<VirtualHost *:80>
ServerName public.domain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://10.10.10.10:81/moodle/
ProxyPassReverse / http://10.10.10.10:81/moodle/
</VirtualHost>
AND.
$CFG->wwwroot = 'http://public.domain.com';
I install without problems, but when finished the installation I try in browser:
http://public.domain.com
This redirect to: http://public.domain.com/moodle/index.php?sessionstarted=1&lang=en...
Does anyone know what might be happening?
The best way to fix this issue is to move the moodle installation on the internal host to the root of web server.
Move your moodle in 10.10.10.10 to be at / and not at /moodle
Note, that if you will use SSL on the external apache (it's suggested) you should also add to your config this line:
$CFG->sslproxy = true;
Finally I have been able to fix the problem, I am writing this answer with a bigger level of detail so other people having this problem can follow my answer.
First we need to edit the apache2 config for our site:
In general the apache2 configuration for your specified site can be found at /etc/apache2/sites-enabled. Depending if you are using http or https you need to edit the right configuration file. Default name for http is 000-default.conf and for https 000-default-ssl.conf
Add the following lines between the <VirtualHost *:80>....</VirtualHost> sections.
# MOODLE
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "http://10.10.10.10:81/moodle/"
ProxyPassReverse "/" "http://10.10.10.10:81/moodle/"
Then we need to restart our apache2 webserver, this can be done with the command service apache2 restart.
Now we also need to edit a few things in our moodle config.php file. This file can be found at /var/www/html/moodle on the server with the IP (in this case) 10.10.10.10 if you used the default install location from the moodle guides.
In the config.php file we append the following lines under the default $CFG declarations: Please make sure to change all values according to your server setup.
$CFG->wwwroot = 'http://public.domain.com';
$CFG->dirroot = '/var/www/html/moodle';
$CFG->reverseproxy = true;
//$CFG->sslproxy = true; //UNCOMMENT this line if you are using SSL
Attention: If you are not using the root directory at your public webserver, then make sure that you do not use the same directory as moodle is using on the subserver. For example http://public.domain.com/moodle will fail if moodle is installed on the subserver at /var/html/moodle since both directories are equal and the proxy loops for some reason. My easy fix for this problem was do just move the moodle installation to /var/html/moodley including all required changes in the config.php. This fixes every problem I had.
I am currently trying to run the program after I have successfully created all the necessary CRUD files. Note that I am following this tutorial here.
However, I am facing problem in trying to run the sites from my cmd. I tried taskmanager.dev but Chrome returned 'This site can’t be reached'.
May I know, is the any specific ways for me to run the site on xampp?
I am using Windows.
Please help. Thank You.
I am quite sure the guy who made the tutorial is using valet.
Just use php artisan serve and you will be able to connect to your site on localhost.
But if you really want to use taskmanager.dev do the following:
Open the hosts file, which is lotcated # C:\Windows\System32\drivers\etc\hosts
Add 127.0.0.1 taskmanager.dev at the bottom
Make sure you follow their installation tutorial closely. It sounds like you may not have configured the server correctly.
For me, I have to edit my VHosts file which is in:
C:\xampp\apache\conf\extra
And to edit my hosts file I need to go to:
C:\Windows\System32\drivers\etc
If all else fails you can always just run php artisan serve in bash to launch your app.
But I would recommend going through these instructions again:
XAMPP Virtual Host
We need to configure XAMPP Virtual Host to set the document root to correct directory of laravel project and to also assign a name to the project by which we will be accessing it in browser.
Navigate and open file /Applications/XAMPP/etc/httpd.conf file and uncomment the line that includes the virtual host file.
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Navigate and open file /Applications/XAMPP/etc/extra/httpd-vhosts.conf and include following Virtual host entry in this file.
# VirtualHost for TASKMANAGER.DEV
<VirtualHost taskmanager.dev:80>
DocumentRoot "C:\xampp\htdocs\taskmanager\public"
ServerAdmin taskmanager.dev
<Directory "C:\xampp\htdocs\taskmanager">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
With this entry our apache is listening to taskmanager.dev, but we also have to edit our hosts file to include an entry for the new domain.
Edit file /etc/hosts and add following entry to that file.
127.0.0.1 taskmanager.dev
Restart your apache and access taskmanager.dev on your browser you should be able to see this screen.
Chrome 63 now enforces .dev domains via HTTPS. Follow this article : https://laravel-news.com/chrome-63-now-forces-dev-domains-https to know more.
I've changed to .test for my valet domains. Hope this helps. Thank you.
For a xampp server I have created a symbolic link.
Now when running the server I get an error:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.7 (Unix) OpenSSL/1.0.1e PHP/5.5.6 mod_perl/2.0.8-dev Perl/v5.16.3
In the project directory I currently only have an index.html file containing:
<!DOCTYPE html>
<html>
<body>
<p>test</p>
</body>
</html>
I have checked all the permissions on both the project directory and the directory the symbolic link is located in.
These are all set to 777.
What could I do to get this to work?
What you have to do is create virtual host in apache configuration.
I would recommend using pure apache without xampp on most unix based systems, but with xampp it's still possible.
Find your apache config directory and head to extra folder, it should be organised with something like: \xampp\apache\conf\extra\
Add listener and virtual host on the bottom of the file like that
ServerName localhost
Listen 8080
<VirtualHost *:8080>
DocumentRoot "diretory/with/index/"
<Directory "directory/with/all/files">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
The main difference between DocumentRoot and Directory is that DocumentRoot must point directly to the place where you index.php is located.
Directory is just poinitng to the all resources places.
For example you can have stuff/public folder in which are located all things that user can access, but also you have some frameworks like laravel which is upper in directory and still needs to be maintained by php interpreter, but shouldn't be accessible directly to the end user
I am running tomcat 7, Ubuntu 14.04, apache 2.4, Java 8. I am trying to hook up apache with mod_jk to use the tomcat application with only the static resources coming from apache.
Apache is running on port 80 and I can see the file structure and all my static resources. But when I go to the naked url, I only see the apache folder structure. In my understanding mod_jk should be forwarding to the ajp port of tomcat instead.
I installed apache2 and mod_jk (libapache2-mod-jk) by using apt-get. It basically did all the configuration for me (at least it looks like it did). I followed some tutorials to install it, but basically just checked and made sure the steps were taken. The main apache conf file is called apache2.conf and it includes all the .conf files from the folder called mods-enabled. Inside mods-enabled, there is a file called jk.conf. This is the mod-jk conf file and it includes a workers.properties file that is held in my /etc/libapache2-mod-jk folder. (I edited the workers.properties file to point to my tomcat home location and my java home)
The one thing that seemed different from most of the tutorials I read was that my mod jk conf file (jk.conf) had no reference to a file called module/mod_jk.so. I don't know what this file is, and why the folder doesn't have a slash in front of it, but that was what it looked like in all the tutorials.
What would really help is if someone has used the apt-get installation of mod_jk on Ubuntu 14.04 (all of the examples I found were for 12.04).
Is the reason it's not connecting because I don't have the .so file?
Am I mistaken about how ajp is suppossed to work, do I need to do any extra tomcat configuration other than have an ajp connector that looks like this <Connector port="8009" protocol="AJP/1.3" redirectPort="8080" />?
I had not added JkMount to apache2.conf. That solved this.
Note: It was tough deciding whether this belonged here or ServerFault, but it seemed like a programming problem, so if it's out of place, feel free to migrate it.
I downloaded the sandbox of Symfony 1.4.8 and copied the files to my webserver. Unfortunately, when I try to access /symfony/sf_sandbox/web/ (where I installed it), I get the following:
It seems like the images aren't showing. According to the text:
If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf/ directory.
However, when I try to locate the folder referenced above, it does not exist:
sf_sandbox
web
css/
images/
js/
uploads/
frontend_dev.php
index.php
robots.txt
As you can see, there is no sf/ directory under web/. What am I doing wrong?
Note: I am installing this on Ubuntu 10.04 64-bit using Apache.
All the images are located in the Symfony source directory.
I would try creating a symbolic link in the web folder called sf pointed to the following:
lib\vendor\symfony\data\web\sf
It should have access to the needed images at that point.
This is done by indicating the right path in the Alias directive in your apache configuration:
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/home/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Just replace "/home/sfprojects/jobeet" with your project's path and it should work.
This page shows the apache config to set up a new project correctly.
There are also important security notes for your webapp.
Symfony Documentation
All you need to do is copy the whole sf folder to the web folder. In my case i copied c:\wamp\www\jobeet\lib\vendor\symfony\data\web\sf\ to c:\wamp\www\jobeet\web. Hope that makes sense