A
A
Alex Bugz2015-07-02 13:45:59
Nginx
Alex Bugz, 2015-07-02 13:45:59

How to redirect from subdomain to nginx ssl domain?

Previously, the site had an account for authorized users on a separate subdomain https://subdomain.domain.ru , under ssl.
Now they issued a certificate only for the main domain, when moving, the following happens - access to https://subdomain.domain.ru is untrusted.
Everything is complicated by the fact that there are subdomains that should work without ssl on port 80. It is necessary to make a redirect from https://subdomain.domain.ru to https://domain.ru
using nginx so that there are no problems with the certificate. This config does not work, although judging by the documentation it should


server {
listen 443 ssl;
server_name domain.ru *.domain.ru;
if ($host = subdomain.domain.ru) {
return 301 $scheme://domain.ru$request_uri;
}
...

I also tried to breed with server directives, but also to no avail.

server {
server_name subdomaun.domain.ru;
return 301 $scheme://domain.ru$request_uri;
}
server {
listen 443 ssl;
server_name domain.ru;
....
}

How to correctly write a rule so that when you directly access an abstract page from bookmarks or a picture from
https://subdomain.domain.ru , Nginx redirects to the main domain https://domain.ru and does not swear at the certificate?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2015-07-02
@winter_jam

No way. Get a free certificate from startssl.com and do a normal redirect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question