Httpd.conf multiple VirtualHost sections (was: Mono ASP.NET MVC AutoHosting issues) - asp.net-mvc

I'm doing exactly this by trying to disable AutoHosting. However now I get "Failed to connect to mod-mono-server after several attempts to spawn the process." in the logs. The path is correct
Here's my config:
<VirtualHost *:80>
ServerName myserver.com
DocumentRoot /home/abe/html/
MonoServerPath myserver.com "/usr/local/bin/mod-mono-server2"
MonoDebug myserver.com true
MonoSetEnv myserver.com MONO_IOMAP=all
MonoAutoApplication disabled
MonoApplications myserver.com "/:/home/abe/html/"
<Location "/">
Allow from all
Order allow,deny
MonoSetServerAlias myserver.com
SetHandler mono
</Location>
</VirtualHost>
Fixed: see the answer below.
With the fix, though, how can I get the configuration I want w/o doing the dangerous process of editing the auto-gen'd httpd.conf?

Turns out this was an issue with the VirtualHost being defined twice - once in httpd.conf and once in vhosts.conf. So the fix was to use just one VirtualHost block. But this causes another problem, unfortunately. I'm in a hosted environment and httpd.conf is auto-generated so I really shouldn't be editing it directly. However it is safe to edit vhosts.conf. VirtualHost is automatically set by my host and injected into httpd.conf.

Related

Apache + Passenger Rails app failing with a 403 error

I currently have a rails app that works locally but at the moment of deploying the app i'm having an error configuring the server.
I followed the steps here, and i'm stuck on step 6. Instead of seeing the rails webpage i got
Inside /etc/apache2/sites-available/tesis.conf i got
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/tesis/public
RailsEnv development
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html/tesis/public">
Options -MultiViews
Require all granted
Allow from all
</Directory>
And the rails app is located at /var/www/html/tesis/public, so that makes sense, but the odd thing is that debugging the apache error logs (/etc/apache2/sites-available/tesis.conf) i see:
[client 143.244.50.172:44448] AH01630: client denied by server configuration: /home/deploy/tesis/public/config
Why apache is going to that path instead of the one i specify on the configuration file?

Tomcat7 / Apache2 URL Wildcard Mapping

I have a Java Servlet that takes the path of a provided URL request and retrieves database resources from it. For example:
www.mydomain.com/gateway/databasename/tablename
Would retrieve information from the specified table, all nice and REST like. This works just fine on a localhost Tomcat7 server on Windows and Netbeans, but I'm having trouble deploying it on an Apache2 web server running Ubuntu.
This is what my VirtualHost file looks like:
<VirtualHost *:80>
ServerAdmin andrew#mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/wordpress
<Directory />
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Alias /manager /usr/share/tomcat7-admin/manager
<Directory "/usr/share/tomcat7-admin/manager">
Options FollowSymLinks
AllowOverride None
Allow from all
</Directory>
JkMount /gateway* ajp13_worker
JkMount /manager* ajp13_worker
JkMount /host-manager* ajp13_worker
ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I'm able to navigate to www.mydomain.com/gateway and view the index page for the servlet. If I go to www.mydomain.com/gateway/databasename, I get a 404 error from Tomcat saying the requested resource is unavailable.
However! If I go to www.mydomain.com/gateway/gateway, I then get my servlet's response that "gateway" is an invalid database name.
So I think the problem is somewhere in the VirtualHost file and mapping the URL. Anything at www.mydomain.com/gateway/gateway/* works, but www.mydomain.com/gateway/* does not.
Also the servlet mapping for my deployment's web.xml is correct:
<servlet-mapping>
<servlet-name>Gateway</servlet-name>
<url-pattern>/gateway/*</url-pattern>
</servlet-mapping>
And the mod-jk's worker.properties file looks right:
worker.list=ajp13_worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
I'm not sure where I'm going wrong, and I know it's going to be something obvious. If anyone can help me out, I'd greatly appreciate it!
My guess is that Tomcat is serving the webapp at the / (root) context path when you run it from Netbeans, and the server is serving it at the /gateway context path.
So from Netbeans the base webapp path is: /hostname
But on the server it is: /hostname/gateway
Since the URL pattern of your servlet is /gateway/*, the result is that on the server you have to add an additional /gateway.
To fix it for the server, you need to change the URL pattern of your servlet to /* instead of /gateway/*
Then to make it work again from Netbeans, you need to change the context path from /ROOT to /gateway. I'm not familiar with Netbeans, but from a quick googling you need to right click your webapp go to Properties -> Run, and there you should be able to change the Context Path.

zend framework skeleton application not showing properly

I have installed the Skeleton Application manually. My application is kept in "D:\xampp\htdocs\zf2". I've created a virtual host in the following way, in httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
<Directory "D:/xampp/htdocs/zf2/public/index.php">
#DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but it does not shown properly and it gives the output
and the remain ing application with module and database shows also not shows in the proper way
but if i slightly modify in virtual host settings of
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
to
DocumentRoot "D:/xampp/htdocs/zf2/public"
then, skeleton application shows fine but when i configure module and database it gives error "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. zend sleleton application error"
can any one help me i have waste lot of time to set it but didn't.
You need to set document root to the folder not a file. The page looks messed up when pointing to index.php as documentroot because it cannot find the stylesheets.
The issue with configuring the module/database is probably a different issue, and you would have to post your module/database configuration to get help there.

Rails not rendering assets over SSL (404 Not Found error)

I am kind of new to Rails and am struggling with an issue that is preventing my assets to be found if I try to access my test app using an SSL connection.
As an example of what I am referring to, if you try to access
http://domain.com/testapp the default rails page loads fine and I have no issues at all.
You can also access a page I created using this route
http://domain.com/testapp/static_pages/home
However the same address, if accessed via HTTPS is returning 404 errors for all of my assets. I am also unable to access any routes (they all return 404).
https://domain.com/testapp
https://domain.com/testapp/static_pages/home
I am currently using an Apache server with Passenger installed, and here is what my virtual host configuration looks like:
<Directory /var/www/testapp/public>
PassengerEnabled on
PassengerAppRoot /var/www/testapp
RailsBaseURI /testapp
</Directory>
Any ideas of why this might be happening?
Thanks,
Rog
Thanks all, I finally figured out what was going on so in the interest of others having the same issue, the virtual host configuration was only being applied to the default port (80) so I had to specify port 443 as well.
<VirtualHost *:80 *:443>
<Directory /var/www/testapp/public>
PassengerEnabled on
PassengerAppRoot /var/www/testapp
RailsBaseURI /testapp
</Directory>
</VirtualHost>
For people using Media Temple's DV server, this configurations has to be specified in two separate files (make sure you remove the VirtualHost tags).
vhost.conf
vhost_ssl.conf
And don't forget to restart apache.
/usr/sbin/apachectl -K graceful

Apache and passenger setup virtualhost restart failing

I have installed passenger on my Ubuntu 10.x server and I am running Apache2. I have followed the instruction "I think" pretty well. After setting up my virtual host and trying to restart I am getting a failed to start apache error because Documentroot takes one argument. I have the document root set is the thing so I am wondering if you guys could offer some suggestions as to what I may be doing wrong.
I have all my virtual hosts in separate files by domain name, so the directory structure on the server is something like this
/etc/apache2/sites-available/dev.mydomain.com
/etc/apache2/sites-enabled/dev.mydomain.com
both files have the following in them but restarting apache only fails when I put the vhost info in the enabled file.
<VirtualHost *:80>
ServerName dev.mydomain.com
DocumentRoot /home/myfolder/dev/vb/public # <-- be sure to point to 'public'!
<Directory /home/myfolder/dev/vb/public>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory>
</VirtualHost>
Thanks for any help you can offer.
Comments in httpd.conf must go on their own line.
have you given before defining VirtualHost
NameVirtualHost *:80
if this given remove those commented line after document root and try

Resources