I run a Rails app on Passenger and it all works like it should.
I want to add a Sinatra app to run as a Rack application with Passenger, but I get a routing error.
My VirtualHosts File looks like:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain1.com
DocumentRoot /home/user1/vhosts/project1/public
ErrorLog /home/user1/vhosts/project1/log/httpd_error_log
CustomLog /home/user1/vhosts/project1/log/httpd_access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.sub.domain2.com
DocumentRoot /home/user2/vhosts/sinatra_app/lib/public
ErrorLog /home/user2/vhosts/sinatra_app/lib/log/httpd_error_log
CustomLog /home/user2/vhosts/sinatra_app/lib/log/httpd_access_log combined
</VirtualHost>
My Sinatra app is really simple; I have a route called get "/do_something" do .... with no public files. it only responds with some JSON.
How can I make it do requests like www.sub.domain2.com/do_something
It seems OK,are the priviledges set correctly?
Related
I'm using Apache2. My server's website (Linode) loads normally only if I include the www.[name].com link. If I use [name].com without the www, I actually receive a page, but it reads the 400 Bad Request Error. Here is my etc/apache2/sites-available files:
website.conf
<VirtualHost *:80>
ServerName website.com
ServerAlias www.website.com
Redirect 301 / https://www.website.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Here is my website-le-ssl.conf file (for HTTPS/SSL):
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.website.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/name/website/static
<Directory /home/name/website/static>
Require all granted
</Directory>
Alias /media /home/name/website/media
<Directory /home/name/website/media>
Require all granted
</Directory>
<Directory /home/name/website/website>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/name/website/website/wsgi.py
WSGIDaemonProcess django_app python-path=/home/name/website/ python-home=/home/name/website/venv
WSGIProcessGroup django_app
SSLCertificateFile /etc/letsencrypt/live/name.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/name.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
In addition, I do not use .htaccess file, I do not use any other redirect file, and I have already enabled the a2enmod rewrite module. This site sometimes works without the non-www, but there are brief periods of time where it doesn't work and I'm confused as to why it acts this way. Is there a way to get Apache2 to redirect from non-www addresses to www addresses, and how do I make the redirect work ALL the time. Thank you!
Things tried:
I've tried using the RewriteEngine and mod_rewrite on the .htaccess file and I've tried completely restoring everything to default and reconfiguring it all from scratch and tutorials.
im new to Zend Framework. Now i have to make some changes to an existing Zend Project. But on my local Xampp Installiation all links doesn't work.
I already set up a virtual host. Since then the Start page work correctly.
<VirtualHost *:80>
DocumentRoot "C:\xampp_54_zend\htdocs\myproject\public"
ServerName myproject
</VirtualHost>
But on every Link i get an error: "Link incorrect oder doesn't exist".
Edit: 404 Error
On the Live-Server everything works correctly.
What can i do to find the error and make the links working?
Try using below configuration:
<VirtualHost *:80>
ServerName myproject
DocumentRoot "C:/xampp_54_zend/htdocs/myproject/public"
DirectoryIndex index.htm index.html index.php
<Directory "C:/xampp_54_zend/htdocs/myproject/public">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I'm trying to get zf2 running on my xampp.
I have this vhosts.conf file
NameVirtualHost 127.0.0.1:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot "C:/xampp/htdocs/zf2-tutorial"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/zf2-tutorial">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
and this host file
127.0.0.1 zf2-tutorial.localhost
Now, when I run zf2-tutorial.localhost, the browser goes to zf2-tutorial.localhost/xampp and shows xampp page.
When I run localhost it goes to localhost/xampp too.
Please help.
Try http://zf2-tutorial.localhost/public
If that works you could change the following entries in your vhosts file
DocumentRoot "C:/xampp/htdocs/zf2-tutorial/public"
<Directory "C:/xampp/htdocs/zf2-tutorial/public">
I'm preparing my ubuntu server in Amazon AWS to host a new website. It uses Apache2. I've done this before with no problem whatsoever, for example, to trick a friend I spoofed google.com and www.google.com (editing his hosts file) and everything worked fine with and without 'www.'.
Now I have bought a domain name 'domain.com' with 1&1 , I have configured a subdomain 'www.domain.com' and I have pointed it to my server. The dns record is fine, I checked. I have also edited my sites-enabled default file and added these entries:
<VirtualHost *:80 >
ServerName www.domain.com
DocumentRoot /var/www/domain
</VirtualHost>
<VirtualHost *:80 >
ServerName domain.com
DocumentRoot /var/www/domain
</VirtualHost>
When I visit domain.com in my browser it works fine, but when I visit www.domain.com I get domain.com/domain/ and obviously a 404.
I used telnet and discovered that the server sends a 301 when you request the root page of host: www.domain.com
I don't know why this is happening, I've tried lots of modifications to the configuration above like:
<VirtualHost *:80 >
ServerAlias www.domain.com
DocumentRoot /var/www/domain
</VirtualHost>
<VirtualHost *:80 >
ServerAlias domain.com
DocumentRoot /var/www/domain
</VirtualHost>
.
<VirtualHost *:80 >
ServerName domain.com
DocumentRoot /var/www/domain
</VirtualHost>
<VirtualHost *:80 >
ServerName www.domain.com
DocumentRoot /var/www/domain
</VirtualHost>
.
<VirtualHost *:80 >
ServerName domain.com
Server Alias www.domain.com
DocumentRoot /var/www/domain
</VirtualHost>
but it kept happening.
For the record, this is what I used for the spoof that still works fine
<VirtualHost *:80 >
ServerName google.com
DocumentRoot /var/www/google
</VirtualHost>
<VirtualHost *:80 >
ServerName www.google.com
DocumentRoot /var/www/google
</VirtualHost>
I've been searching for two days now, but all I find is the same configuration I'm using and no explanation about why this isn't working.
Thanks for your help!
PS: There are no .htaccess files in this directory or in any of the parent directories.
In case anybody enters this question.
I still don't know what was wrong but after moving these configurations around the file they've magically started working normally.
Thanks to everybody who took the time to read the question.
Its better to put
<VirtualHost *:80 >
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain
</VirtualHost>
You can't put a space between Server and Alias so I changed to show you
Hope It Works!
I would like to protect a web folder via .htpasswd.
However, as the .htaccess file is under version control, I would prefer to not mess with it.
Instead, I would like to have the configuration in
/etc/apache2/sites-enabled/mysite
/etc/apache2/.htpasswd
Any idea what I need to put in the "mysite" apache configuration file?
So far it is sth like this,
<VirtualHost (ip address):80>
ServerName my.domain
DocumentRoot /var/sites/sitename
ServerAdmin ...
</VirtualHost>
Heureka, I figured it out myself.. or what I think to be the solution.
<VirtualHost (ip address):80>
ServerName my.domain
DocumentRoot /var/sites/sitename/
ServerAdmin ...
<Directory /var/sites/sitename/>
AuthUserFile /etc/apache2/.htpasswd
AuthGroupFile /dev/null
AuthName "What is the pw"
AuthType Basic
require user (username)
</Directory>
</VirtualHost>
The .htpasswd can be created in the usual way via commandline,
# htpasswd /etc/apache2/.htpasswd (username)
EDIT: anthony in the comment below strongly recommends you use https/SSL, to prevent the password from being sent unencrypted.