Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

How do I redirect all traffic to the https:// domain?

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
5 posts • Page 1 of 1
Spythe
Posts: 9
Joined: Wed Jun 21, 2017 7:15 pm

How do I redirect all traffic to the https:// domain?
  • Quote

Post by Spythe » Thu Jun 22, 2017 10:18 am

Hey guys,

I've setup Vesta and added SSL support for all domains with Let's Encrypt. When manually typing https://domain.com it'll show the site with SSL turned on, but when I just type domain.com it'll always navigate to the non-SSL http:// variant.

How do I make all traffic, per domain or all domains all together (since all domains will have SSL) go automatically to https://domain.com ?

I already googled and saw lots of suggestions, including server {} blocks, which I pasted within the http {} part in the /etc/nginx/nginx.conf file and restarted the server, but that didn't change a thing..
Top

shanjie
Posts: 37
Joined: Thu Jan 14, 2016 12:02 pm

Re: How do I redirect all traffic to the https:// domain?
  • Quote

Post by shanjie » Fri Jun 23, 2017 12:44 am

https://vestacp.com/docs/#how-to-force-https
Top

castris
Posts: 4
Joined: Tue Feb 18, 2020 7:43 am

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: How do I redirect all traffic to the https:// domain?
  • Quote

Post by castris » Thu Dec 31, 2020 11:56 am

Post is older but doc is actual.
How to force https/SSL on a domain
1. Install custom nginx template

Code: Select all

cd /usr/local/vesta/data/templates/web
wget http://c.vestacp.com/0.9.8/rhel/force-https/nginx.tar.gz
tar -xzvf nginx.tar.gz
rm -f nginx.tar.gz
3. Create new package or set force-https as nginx template in the existing package
4. Add new user and assing him package with force-https template
5. Add new domain with SSL certificate and check the result
Well...

After step 2, there're in /usr/local/vesta/data/templates/web/nginx/ two new files, force-https.stpl and force-https.tpl

Step 3 create a package or force-https no work using any template named force-https

Any template named force-htpps on VestaCP interface, in new template or on domain for apply new template.

What is wrong?




I'm using vestaCp 0.9.8 Release 26
Top

nehavilash
Posts: 12
Joined: Sat Jul 15, 2023 9:33 am
Contact:
Contact nehavilash
Website Facebook Twitter

Os: CentOS 7x
Web: apache + nginx
Re: How do I redirect all traffic to the https:// domain?
  • Quote

Post by nehavilash » Wed Jul 19, 2023 3:47 pm

Hi,

You can configure the server block to redirect all traffic to the HTTPS version of your domains.
Here's how:
1. Go to Nginx configuration  '/etc/nginx/conf.d/'.
2. Create a new configuration file for redirection.
3. Edit  https-redirect.conf and paste the below code.

Code: Select all

server {
    listen 80;
    server_name domain.com www.domain.com;

    location / {
        return 301 https://domain.com$request_uri;
    }
}
4, Save it then test the Nginx configuration.

Code: Select all

nginx -t
5. If everything is correct, you should see a message 
Finlay restart to apply changes.

Code: Select all

systemctl reload nginx
Manually check individual urls or use any online tool such as this https://redirectchecker.com/ to get a detailed redirection chain and its status code.
I hope the above steps help.
Top

slipchant
Posts: 8
Joined: Tue Jun 20, 2023 7:52 am

Os: Debian 6x
Web: apache + nginx
Re: How do I redirect all traffic to the https:// domain?
  • Quote

Post by slipchant » Tue Sep 26, 2023 4:26 am

shanjie wrote: ↑
Fri Jun 23, 2017 12:44 am
https://vestacp.com/docs/#how-to-force-https geometry dash world
Wow, This guide is very useful to me.
Top


Post Reply
  • Print view

5 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password