Welcome! Log In Create A New Profile

Advanced

Re: Rewrite rules for port 80 and 443;

António P. P. Almeida
December 20, 2010 08:36PM
On 21 Dez 2010 01h06 WET, david@styleflare.com wrote:

> How am I able to use the same rewrite rule for both port 80 and 443?

Try this:

server {
## This is to avoid the spurious if for sub-domain name
## rewriting. See http://wiki.nginx.org/Pitfalls#Server_Name.
listen [::]:80; # ipv6
listen [::]:443 ssl; # ipv6
server_name example.com;

## Server certificate and key.
ssl_certificate /etc/ssl/certs/example.com-cert.pem;
ssl_certificate_key /etc/ssl/private/example.com-key.pem;

## Use only HTTPS.
rewrite ^ https://www.example.com$request_uri? permanent;
} # server domain rewrite.

> It seems like nginx complains if you try to run multiple sites on
> port 443 with one cert?

It should, each site needs a *different cert* or a cert that supports
several Alternative Names: www.example.com www.example.net, &c.

Cf. http://nginx.org/en/docs/http/configuring_https_servers.html

> The rewrite rule simple add www. to the domain should a person type
> the domain without it;

See above.

hth,
--- appa


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite rules for port 80 and 443;

David J. December 20, 2010 08:08PM

Re: Rewrite rules for port 80 and 443;

António P. P. Almeida December 20, 2010 08:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 152
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready