New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Nginx ssl redirect
hello guys newbie need some help here
i got 2 domain both with valid ssl cert, i want to redirect AAA domain to BBB domain with AAA cert to keep transfer green
the BBB config all good, but AAA have problem
sudo ln -s /etc/nginx/sites-available/AAA.net /etc/nginx/sites-enabled/AAA.net
sudo ln -s /etc/nginx/sites-available/BBB.net/etc/nginx/sites-enabled/BBB.net
AAA config
server { listen 80; listen 443 ssl; ssl_certificate /etc/nginx/SSL/server.crt; ssl_certificate_key /etc/nginx/SSL/server.key; server_name www.AAA.net AAA.net; root /var/www/AAAA.net; #rewrite ^(.*) https://www.BBB.net$1 permanent; return 301 https://www.BBB.net$request_uri; }
all AAA non ssl OK redirect to www.BBB.net (SSL)
AAA/* to BBB/* ssl
but the AAA SSL not redirect to BBB (SSL)
?
nginx 1.7.6
Thanked by 1linuxthefish
Comments
Not sure why you need the rewrite statement. 301 status already denotes permanent redirect.
should be adequate. Maybe that was interfering with the redirect?
ya can opt-out that line, but still only non ssl working, ssl blank page not redirect
the AAA root directory is just dummy, can be removed to
is there any possible way to do it smoothly there is alternative redirect but scarifying the ssl which is really not ok
This is what I'm using:
that might be working on current domain only, not to redirect to BBB ssl
Try
rewrite ^ https://www.BBB.com$request_uri? permanent;
^ not gonna work
btw any BBB config modification are welcome
im gooling like 6 hour for any possible solution still not found answer, becaused im dummy -_-
Have you look at the access/error log?
Mas @rokok, bisa dicoba konfigurasi ini:
Site AAA:
Saya pakai konfigurasi ini untuk redirect dari situs AAA yang non-ssl ke situs BBB yg SSL
english please
You need atleast 3 virtual host config (server block)
1 - AAA non SSL => BBB
2 - AAA SSL => BBB
3- BBB
here example
You don't need three virtual hosts; Nginx can handle multiple ports with optional SSL in a single server statement.
To be honest, something is amiss. The originally posted config with the return directive (not rewrite) should work just fine. I've used similar configs myself without issue. @rokok needs to check Nginx's logs to see what's happening.
@rokok, are you sure the config files are being included? My default nginx.conf file only includes sites-enabled/*.conf and based on the symlinks you posted your conf files do not end with that extension.
Hi, all sorry fall aspleep
@Bayu the root directory are empty can be ignored, as said before its working on all non ssl, only https not working, need to get it works without interception leaving AAA and identity changed to BBB.
@vonlulzweg i got your idea, its working just for non ssl, the https on AAA shows blank page
@JustAMacUser there is no issue with symlinks all in correct order. a went to a b went to b default goes to default.
this running on 1 vps, sni ssl just the BBB config im using
listen 443 default spdy ssl;
AAA config just use regular 433;
also dont think this was problerm
Ahaaa got it working !
thanks all guys!
here's my solution:
https://paste.ee/p/18Opf#g6LukKqMotCE30qrJO0Mo7rX2hb65iBU