http->https redirection on the same port
Igor Sysoev
is at rambler-co.ru
Thu Jun 19 00:21:31 MSD 2008
On Wed, Jun 18, 2008 at 01:05:26PM -0700, Michael Nachbaur wrote:
> On 17-Jun-08, at 9:11 AM, Igor Sysoev wrote:
>
> >On Tue, Jun 17, 2008 at 08:55:35AM -0700, Michael Nachbaur wrote:
> >
> >>Hi, I'm currently migrating from Apache to lighttpd, but ran into a
> >>blocker that I can't seem to find my way around. So I'm looking into
> >>using nginx instead, but I wanted to ask if my blocker exists here as
> >>well.
> >>
> >>I have a web application running on a high port number. It needs to
> >>be SSL encrypted, but I need to redirect the browser to https:// URLs
> >>automatically if they leave it as standard HTTP. For instance:
> >>
> >>http://my.app:8000 -> https://my.app:8000
> >>
> >>I can't use different port numbers. Apache supports this quite well,
> >>and while supposedly lighttpd supports this in its most recent
> >>version, I've been having some really weird problems I've been
> >>tracking down.
> >>
> >>Does anyone know if this is possible with nginx? I'll make the
> >>switch
> >>in a second if it is. Thanks.
> >
> > server {
> > listen 8000;
> >
> > ssl on;
> > #other ssl stuff
> >
> > error_page 497 https://my.app:8000$request_uri;
> >
> > ...
> > }
> >
> >The 497 code means that a usual request was sent to HTTPS.
>
> Is it possible to do this in such a way that I don't have to encode
> the hostname in the configuration file? We would like to redirect
> requests to the original name our host was talked to with, e.g.
> http://1.2.3.4:8000 should redirect to https://1.2.3.4:8000, whereas
> http://my.app:8000 should redirect to https://my.app:8000.
error_page 497 https://$http_host:8000$request_uri;
> >BTW, how had you implemented this in Apache ?
>
> We built this with an ugly CGI script that handled the redirection. I
> can't remember off the top of my head how this is built, because it
> was written before my time. Lighttpd supports a "$HOST[scheme]"
> variable that can be used to handle request configuration, but it
> seems to be buggy.
I had asked because last time I checked this, Apache simply returned 400
for a plain HTTP request sent to a HTTPS server. I'm curious how do
you pass the request to CGI script ?
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list