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

Redirect https to https://www

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Redirect https to https://www
  • Quote

Post by mehargags » Tue Jun 07, 2016 5:43 pm

Hello All,
need some advise in redirecting my SSL domain properly. I have the Certiuficates in place. This is what I have in the Configs

/home/admin/conf/web/nginx.conf

Code: Select all

server {
    listen      111.222.333.444:80 ;
    server_name domain.com www.domain.com;
    return	301 https://www.$server_name$request_uri;

/home/admin/conf/web/snginx.conf

Code: Select all

server {
    listen      111.222.333.444:443 ssl http2;
    server_name domain.com www.domain.com;
Now this is the scene when I type the URL:

domain.com redirects properly to https://www.domain.com
but
typing in https://domain.com (non-www) does NOT redirect to https://www.domain.com.

Am I doing it in correctly ?
Top

Mr.Erbutw
Posts: 1040
Joined: Tue Apr 29, 2014 10:05 pm

Os: CentOS 6x
Web: apache + nginx
Re: Redirect https to https://www
  • Quote

Post by Mr.Erbutw » Tue Jun 07, 2016 6:07 pm

https://vestacp.com/docs/#how-to-redirect-http-https
https://vestacp.com/docs/#how-to-force-https
http://nginx.org/en/docs/http/convertin ... rules.html

Code: Select all

server {
    listen      000.000.000.000:80;
    server_name  www.mydomain.com;
    return       301 http://mydomain.com$request_uri;
}

server {
    listen      000.000.000.000:80;
    server_name mydomain.com;
    root        /home/user/web/mydomain.com/public_html;
....................................
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: Redirect https to https://www
  • Quote

Post by mehargags » Tue Jun 07, 2016 6:23 pm

I thought so but Since Vesta creates the server block by default like like

Code: Select all

 server_name domain.com www.domain.com
I was hesitant to change it to two different blocks. is that the only way ?
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: Redirect https to https://www
  • Quote

Post by mehargags » Sun Jun 12, 2016 7:12 am

Well, I resolved the issue... I think somehow the Cert. generated did not have naked domain covered. Reissued with

Code: Select all

-d www.domain.tld -d domain.tld
and all htaccess rules started working. Silly...!

Now I wanted to NOT use htaccess and let nginx redirect to https://www. If I write

Code: Select all

return   301 https://www.domain.com$request_uri;
in the listen 172.110.20.76:443; Server block, it stops the whole site... while the same rule works for nonhttps port 80 correctly. What is wrong in here... any clues ?
Top


Post Reply
  • Print view

4 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