Support #2115
openRunning staging server subdomain on same server as production
0%
Description
I've got a staging deployment under fin. subdomain. Is there anything that I should know about how to make that work?
Presently I'm copying my binary to the /var/www/fin/html folder. When I try to call the fin.domain-name.com I get a 403. I've set this up with virtual hosts on Apache many times using other frameoworks, but I cannot figure out why it won't work in Witty.
Updated by Bud T over 11 years ago
This was an issue setting up a self signed wildcard certificate. Nothing to to with Wt. I fixed my cert and can call both www and fin from http and https. I have one final problem remaining on this matter, however, which is that authentication doesn't work within the subdomain (only works in www).
<VirtualHost *:80>
ServerName www.app+name.com
ServerAlias fin.app+name.com
setEnv staging
FcgidInitialEnv WT_APP_ROOT /var/www/fin/application
DocumentRoot /var/www/fin/html
AddHandler fcgid-script .wt
DirectoryIndex app+name-fin.wt
<Directory /var/www/fin/html>
ServerSignature Off
#Order Allow,Deny
#Allow from all
AuthType Digest
AuthName "Private"
AuthUserFile /var/www/passwd/digst
Require user fin-usr
Options +ExecCGI -Indexes
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.fin.app+name\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fin\.app+name.com/$1 [R=301,L]
SetOutputFilter Deflate
AddOutputFilterByType DEFLATE text/html
ScriptAlias /cgi-bin/ /var/www/fin/cgi-bin
</VirtualHost>
If I set up auth as shown in directory above, I get 403; while if I apply the same code in www the authentication mechanism works fine. Have you guys run in to this issue?
Updated by Bud T over 11 years ago
Regardless of the problems using AuthType Digest, what is the story with Apache rewrites? My rewrite rules are not getting applied even if they are placed within an .htaccess file (instead of the virtual host).
Updated by Bud T over 11 years ago
I need an example of virtual hosts setup with multiple subdomains, wildcard ssl, and Apache using fcgid and rewrites set up on a Linux box. Can someone direct me to such an example? If I can't even get the rewrites to work I'm not sure what the point is in continuing to experiment with this framework.
Updated by Bud T over 11 years ago
Here is the deal. I'm using Apache2 mod_rewrite module with the following located within /var/www/html/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
AddHandler fastcgi-script .fcgi
RewriteBase /
RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^/(.*) http://www.domain.com/$1 [R=301,L]
</IfModule>
My expectation is that when user calls domain.com they should be redirected to www.domain.com. What is actually happening is absolutely nothing. The rewrite log entries for call to http://domain.com are shown below:
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri ''
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6975390/subreq] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/app.wt -> app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri ''
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6975390/subreq] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri 'app.wt'
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6991be0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/app.wt -> app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6991be0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri 'app.wt'
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6991be0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/app.wt -> app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri 'app.wt'
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd69773a0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6991be0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6991be0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri ''
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd6991be0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/
##.##.##.## - - [20/Aug/2013:11:11:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd697bc30/subreq] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
##.##.##.## - - [20/Aug/2013:11:16:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd698fbd0/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
##.##.##.## - - [20/Aug/2013:11:16:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd698fbd0/initial] (3) [perdir /var/www/html/] applying pattern '^/(.*)' to uri ''
##.##.##.## - - [20/Aug/2013:11:16:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd698fbd0/initial] (1) [perdir /var/www/html/] pass through /var/www/html/
##.##.##.## - - [20/Aug/2013:11:16:04 --0700] [domain.com/sid#7fcfd692aba8][rid#7fcfd697fc50/subreq] (1) [perdir /var/www/html/] pass through /var/www/html/app.wt
Updated by Bud T over 11 years ago
I see that embweb just put out a release candidate. Congratulations. I intent to install it on my rebuild this weekend. No doubt you guys have more important things to handle than my problems, so it is understandable if you don't get to these questions of mine...
Latest:
Adding +FollowSymLink in the .htaccess file allowed rewrites to function, but for my life I cannot get them to do so properly. SSL mostly works except for the rewrite issue: my setup will redirect http://domain.com to http://www.domain.com but not https://domain.com to https://www.domain.com.
The .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /
# Externally redirect from non-www, non-canonical hostname to the
# canonical www hostname, preserving current HTTP/HTTPS protocol
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule (.*) http%2://www.domain.com/$1 [R=301,L]
</IfModule>
The virtual hosts file:
<IfModule mod_fcgid.c>
NameVirtualHost *:80
NameVirtualHost *:443
FcgidMaxProcesses 150
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com
setEnv SCHEMA prod
FcgidInitialEnv WT_APP_ROOT /var/www/appl
DocumentRoot /var/www/html
AddHandler fcgid-script .wt
DirectoryIndex stapp.wt
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
RewriteLog /var/log/httpd/rewrite_log.txt
RewriteLogLevel 1
<Directory /var/www/html>
ServerSignature Off
Order Allow,Deny
Allow from all
Options +ExecCGI -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias fin.domain.com
setEnv SCHEMA prod
FcgidInitialEnv WT_APP_ROOT /var/www/fin/appl
DocumentRoot /var/www/fin/html
AddHandler fcgid-script .wt
DirectoryIndex app-fin.wt
ErrorLog /var/log/httpd/fin_error_log
CustomLog /var/log/httpd/fin_access_log combined
RewriteLog /var/log/httpd/fin_rewrite_log.txt
RewriteLogLevel 5
<Directory /var/www/fin/html>
ServerSignature On
#Order Allow,Deny
#Allow from all
AuthType Digest
AuthName "Private"
AuthDigestDomain / http://fin.domain.com/
AuthUserFile /var/www/passwd/digst
AuthGroupFile /dev/null
Require user fin-usr
Options +ExecCGI -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName www.domain.com
ServerAlias domain.com
setEnv SCHEMA stage
FcgidInitialEnv WT_APP_ROOT /var/www/appl
DocumentRoot /var/www/html
AddHandler fcgid-script .wt
DirectoryIndex app.wt
ErrorLog /var/log/httpd/ssl_error_log
CustomLog /var/log/httpd/ssl_access_log combined
RewriteLog /var/log/ssl_rewrite_log.txt
RewriteLogLevel 1
RewriteCond %{HTTPS_HOST} ^domain\.com [NC]
RewriteCond %{HTTPS_HOST} !^$
RewriteRule ^/(.*) https://www.domain.com/$1 [R=301,L]
SSLEngine On
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
# Use below for self signed CA
SSLCertificateFile /etc/pki/myCA/certs/server.crt
SSLCertificateKeyFile /etc/pki/myCA/private/server.key
SSLVerifyClient optional
SSLProtocol All
<Directory /var/www/html>
ServerSignature Off
Order Allow,Deny
Allow from all
Options +ExecCGI -Indexes
</Directory>
SetOutputFilter Deflate
AddOutputFilterByType DEFLATE text/html
ScriptAlias /cgi-bin/ /var/www/fin/cgi-bin
</VirtualHost>
<VirtualHost *:443>
ServerName www.domain.com
ServerAlias fin.domain.com
setEnv SCHEMA stage
FcgidInitialEnv WT_APP_ROOT /var/www/fin/appl
DocumentRoot /var/www/fin/html
AddHandler fcgid-script .wt
DirectoryIndex stapp-fin.wt
ErrorLog /var/log/httpd/fin_ssl_error_log
CustomLog /var/log/httpd/fin_ssl_access_log combined
RewriteLog /var/log/fin_ssl_rewrite_log.txt
RewriteLogLevel 5
RewriteCond %{HTTPS_HOST} ^domain\.com [NC]
RewriteCond %{HTTPS_HOST} !^$
RewriteRule ^/(.*) https://www.domain.com/$1 [R=301,L]
SSLEngine On
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
# Use below for self signed CA
SSLCertificateFile /etc/pki/myCA/certs/server.crt
SSLCertificateKeyFile /etc/pki/myCA/private/server.key
SSLVerifyClient optional
SSLProtocol All
<Directory /var/www/fin/html>
ServerSignature Off
Order Allow,Deny
Allow from all
Options +ExecCGI -Indexes
</Directory>
SetOutputFilter Deflate
AddOutputFilterByType DEFLATE text/html
ScriptAlias /cgi-bin/ /var/www/fin/cgi-bin
</VirtualHost>
</IfModule>
The AuthDigest only works in /var/www/html and not in /var/www/fin/html. I can't believe how many hours I've spend trying to figure this stupid thing out today.
My hosts file looks like this:
99.99.99.99 domain.com st
2001:4701:4817:0071:ef59:b0c0:ff10:0bd3 sn
11.11.11.11 sn
127.0.0.1 localhost sn.local. sn fin.sn www.sn
ServerName www.domain.com
ServerAlias domain.com