http to https rewrite, non-standard port?
Igor Sysoev
igor at sysoev.ru
Mon Dec 6 15:00:59 MSK 2010
On Mon, Dec 06, 2010 at 11:47:10AM +0000, John Moore wrote:
> I want to rewrite all http requests for a host to https, on port 9443
> instead of the the standard 443. So I have this in my nginx.conf:
>
> server {
> server_name www.domain.com;
> listen 80;
> location / {
> rewrite ^(.*)$ https://$host:9443$1 permanent;
> }
> }
>
> server {
> server_name www.domain.com;
> listen 9443;
> location / {
> #etc...
> }
> }
>
>
> And as long as I use 'http://www.domain.com', the rewrite works fine.
> But some URLS are coming back now as 'http://www.domain.com:9443' and
> I'm running into the 400 error"The plain HTTP request was sent to HTTPS
> port", for obvious reasons. So how do I get it to rewrite 'http://' to
> 'https://' as well, which is what I presume I need to do?
error_page 497 https://$host:9443$request_uri;
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list