Redirect to SSL

ZipperZapper

Verified User
Joined
Nov 30, 2015
Messages
142
I've been staring at this all weekend and I don't know if I'm overlooking something. I'm using Nginx-only and made some adjustments to my config files, so far, so good.

But if you enable SSL on a website, and you would like to make it default and set a rewrite, how would you do that? The easiest way would be changing nginx_server.conf in this:

Code:
server
{
        listen |IP|:|PORT_80|;
        |MULTI_IP|

        server_name |DOMAIN| www.|DOMAIN|;
        return 301 https://|DOMAIN|$request_uri;
}

But then it will never me able to use a plain-text website, so that's not a good way. It's also possible to make some changes with Custom HTTPD Configurations, but a rewrite to https will then also be included in the server block where ssl is enabled. I don't think that's the right way either, is it?

What would be a good way to force a particular website to redirect to https?
 
I didn't touch nginx.server.conf. I just edited:

/usr/local/directadmin/data/users/**USER**/nginx.conf

And there i edited the server port 80 block to redirect to https. To block CustomBuild from overwriting this user config, i use this;

Code:
chattr +i nginx.conf

To unlock the file use -i

Works great for me!
 
Sometimes you need a beer to see the light. It's quite easy. If you want a particular website to force redirect to https, you can put this in a custom field:

Code:
|*if SSL_TEMPLATE="0"|
        return 301 https://|DOMAIN|$request_uri;
|*endif|

Works like a charm!

By the way: these ''Random Questions" are too hard! I keep turning to Google for answers. I mean "Two Four Six Eight, who do we ___ ?". What?! Maybe it's something you learn at school over in the US or Canada, but to me it's a mystery :eek:
 
old and goodie, worked on custom #4

Sometimes you need a beer to see the light. It's quite easy. If you want a particular website to force redirect to https, you can put this in a custom field:

Code:
|*if SSL_TEMPLATE="0"|
        return 301 https://|DOMAIN|$request_uri;
|*endif|

Works like a charm!

By the way: these ''Random Questions" are too hard! I keep turning to Google for answers. I mean "Two Four Six Eight, who do we ___ ?". What?! Maybe it's something you learn at school over in the US or Canada, but to me it's a mystery :eek:
 
Tried this but I get an syntax error message 'return' is not recognized.
After carefully reading the opening post it is for Nginx.

I was trying to add this to "Custom HTTPD Configurations" which modifies httpd.conf

My setup is Apache with Nginx as a reverse proxy. So it would be nice to also have the option in DA panel for "Custom NGINX Configurations".

How can I redirect to SSL with Custom HTTPD Configurations? (Want to get rid of the htaccess redirection)
 
Back
Top