Caucho Forums  

This forum is permanently closed because of spam. For free community support, please visit Google Groups:


Go Back   Caucho Forums > Resin

Reply
 
Thread Tools Display Modes
  #1  
Old 05-25-2012, 02:32 PM
Lehabey Lehabey is offline
Junior Member
 
Join Date: Mar 2012
Posts: 10
Default Redirect http to https almost working

I'm trying to tell Resin (4.0.26) to redirect all http requests to https. Followed this document: http://www.caucho.com/resin-3.1/doc/...ohttpsrequests
and added configuration as described there:
<host ... >
<rewrite-dispatch>
<redirect regexp="^" target="https://${host.name}">
<when secure="false"/>
</redirect>
</rewrite-dispatch>
...
</host>

When I open website I get redirected to 'https://default/'. It seems that host.name is initialized to that value. To confirm I open non-existent link and get 404 page with "Resin/4.0.26 Server: 'default' " at the bottom.

My question is how do I configure host.name properly or can I use any other environment variables?
Looked at http://wiki.caucho.com/Rewrite-dispatch, http://www.caucho.com/resin-3.0/config/control.xtp but didn't find anything useful.

Thanks
Reply With Quote
  #2  
Old 06-06-2012, 07:48 AM
RICK RICK is offline
Member
 
Join Date: Mar 2012
Location: New York
Posts: 30
Default Resin 4 docs

The Resin 4 docs are here for this:

http://www.caucho.com/resin-4.0/admi...ohttpsrequests
Reply With Quote
  #3  
Old 06-06-2012, 07:51 AM
RICK RICK is offline
Member
 
Join Date: Mar 2012
Location: New York
Posts: 30
Default You configure host name in host tag

http://caucho.com/resin-4.0/reference.xtp#host

Code:
<host host-name="www.foo.com">
  <host-alias>foo.com</host-alias>
  <host-alias>web.foo.com</host-alias>

  <root-directory>/opt/www/www.foo.com</root-directory>

  <web-app id="/" root-directory="webapps/ROOT">
    
  </web-app>
  ...
</host>
Reply With Quote
  #4  
Old 06-13-2012, 05:46 PM
Lehabey Lehabey is offline
Junior Member
 
Join Date: Mar 2012
Posts: 10
Default host and host alias

Thanks Rick,

I think configuring host tag will help. I will try and report results here.
I didn't know you can have an alias because this web server has multiple DNS names, and aliases will definitely help.

Cheers
Reply With Quote
  #5  
Old 06-21-2012, 08:50 PM
Lehabey Lehabey is offline
Junior Member
 
Join Date: Mar 2012
Posts: 10
Default Still having trouble with it

I tried this format to define host name that I could use in url rewrite:

<host regexp="([^.]+)\.foo\.com">
<host-name>${host.regexp[1]}.foo.com</host-name>
<root-directory>/var/resin/hosts/www.${host.regexp[1]}.com</root-directory>
...
</host>

I get an error: "regexp="([^.]+)" is an unexpected attribute in <host>"



Then I tried:
<host id="" host-name="hostname1" root-directory=".">
<host-alias>hostname2</host-alias>
<host-alias>hostname3</host-alias>
...
and
...
<redirect regexp="^" target="https://${host.name}">

This sortof works by actually redirecting to hostname1, but it does not use aliases, and I don't know how to tell it to use the hostname that was used in URL.

Resin gurus pls help
Reply With Quote
  #6  
Old 06-21-2012, 08:52 PM
Lehabey Lehabey is offline
Junior Member
 
Join Date: Mar 2012
Posts: 10
Default the same question on stackoverflow

http://stackoverflow.com/questions/1...uests-to-https
Reply With Quote
  #7  
Old 06-21-2012, 11:13 PM
RICK RICK is offline
Member
 
Join Date: Mar 2012
Location: New York
Posts: 30
Default hmmm

If you can capture it with regex you can use it in the target.

Code:
<web-app xmlns="http://caucho.com/ns/resin"
            xmlns:resin="urn:java:com.caucho.resin">

  <resin:Redirect regexp="^/([^/]+)/([^/]+)" target="/$2/$1"/>
	    
</web-app>
Do you need a little regex tune up?

Match the start
^

Look for a forward slash
/

Match group 1
([^/]+) This becomes $1

Match group 2
/([^/]+) This becomes $2

Let me break that down
([^/]+)

Parens are groups
()

Characters
[]

Here the ^ means not.

The + means at least 1 but maybe more....

You probably want a regex like this

http://([^/?#]*)(.*)

I tested it with these.

http://foo.com/bar/baz/love/bug
http://foo.com
http://foo.com?foo=bar
http://foo.com#foo=bar

Code:
<web-app xmlns="http://caucho.com/ns/resin"
            xmlns:resin="urn:java:com.caucho.resin">

  <resin:Redirect regexp="http://([^/?#]*)(.*)" target="http://mynewpath/$2"/>
	    
</web-app>

Code:
<web-app xmlns="http://caucho.com/ns/resin"
            xmlns:resin="urn:java:com.caucho.resin">

  <resin:Redirect regexp="http://([^/?#]*)(.*)" target="http://$1.domain.com/$2"/>
	    
</web-app>
If you give me some more details about what you want to do... I can be more clear.
Reply With Quote
  #8  
Old 06-22-2012, 12:40 AM
RICK RICK is offline
Member
 
Join Date: Mar 2012
Location: New York
Posts: 30
Default ooppss I see what you are asking now... sorry for the Regex explanation.... :)

ooppss I see what you are asking now... sorry for the Regex explanation....

brb
Reply With Quote
  #9  
Old 06-22-2012, 01:21 AM
RICK RICK is offline
Member
 
Join Date: Mar 2012
Location: New York
Posts: 30
Default Here are some working examples from our integration tests

Code:
  <cluster id=''>
    <host regexp='([^.]+)\.([^.]+)\.com' root-directory='/$1'>
      <web-app url-regexp='/([^-]+)-([^/]*)' document-directory='$1'>
        <log path='file:/tmp/caucho/qa/${webApp.regexp[2]}/${host.regexp[2]}/${webApp.regexp[1]}/error.log'/>
      </web-app>
    </host>
  </cluster>
Code:
  <cluster id=''>
    <host regexp='([^.]+)\.([^.]+)\.com' root-directory='/$regexp[1]'>
      <log path='/${regexp[2]}/$host1/error.log'/>
      <access-log path='/$host2/$host1/access.log'/>
      <web-app id='/'>
        <error-page location='/error.jsp'/>
      </web-app>
    </host>
  </cluster>
Code:
<resin xmlns="http://caucho.com/ns/resin">
  <cluster id=''>
    <host id='foo.com' root-directory='/realfoo'>
      <web-app id='/'/>
    </host>
    <host regexp="([^.]+).com$" root-directory='/$1'>
      <web-app id='/'/>
    </host>
  </cluster>
</resin>
Reply With Quote
  #10  
Old 06-28-2012, 10:32 AM
davidwells davidwells is offline
Junior Member
 
Join Date: Jun 2012
Posts: 1
Default

I wanted to setup a 301 redirect from my site but couldn't figure out how to do it. Will anybody help me please.
Reply With Quote
Reply

Tags
https, rewrite-dispatch

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:36 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.