Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Modification & Patches
  • Search

Recommended way to redirect server IP to Domain?[Self Solve]

Section with modification and patches for Vesta
Post Reply
  • Print view
Advanced search
8 posts • Page 1 of 1
weirdaljr
Posts: 14
Joined: Tue Jul 28, 2015 2:46 pm

Recommended way to redirect server IP to Domain?[Self Solve]
  • Quote

Post by weirdaljr » Fri Oct 02, 2015 6:32 pm

Right now I run one site on Vesta and it has SSL on it. Currently by default when you go to http://111.111.111.111 it shows the "default.domain - Powered by VESTA" default page for a new site. I just want the http://111.111.111.111 to redirect to http://domain.com or https://domain.com as http://domain.com already goes to https://domain.com.

Which conf is best to put this in and what method?
Last edited by weirdaljr on Tue Oct 06, 2015 1:04 am, edited 1 time in total.
Top

weirdaljr
Posts: 14
Joined: Tue Jul 28, 2015 2:46 pm

Re: Recommended way to redirect server IP to Domain?
  • Quote

Post by weirdaljr » Mon Oct 05, 2015 8:47 pm

Has anyone been able to do this with Vesta?
Top

weirdaljr
Posts: 14
Joined: Tue Jul 28, 2015 2:46 pm

Re: Recommended way to redirect server IP to Domain?
  • Quote

Post by weirdaljr » Tue Oct 06, 2015 1:04 am

With my 1 ip server I was able to figure out how to do it by editing the one nginx conf below. This worked for me on a 1 IP VPS running Ubuntu with default templates:

/etc/nginx/conf.d/[IP ADDRESS].conf

Code: Select all

server {
    listen       [IP ADDRESS]:80 default;
    server_name  _;
    access_log  /var/log/nginx/[IP ADDRESS].log main;
    location / {
         return 301 https://DOMAINNAME.com;
   }
}
Top

thunder1
Posts: 5
Joined: Tue Feb 04, 2014 9:52 pm

Re: Recommended way to redirect server IP to Domain?[Self Solve]
  • Quote

Post by thunder1 » Thu Dec 06, 2018 2:54 pm

I know is way later,but I can confirm that is working on CentOS 7 too, same 1 IP, VPS.
Top

mailarn
Posts: 46
Joined: Tue Feb 12, 2019 2:38 pm

Os: CentOS 6x
Web: apache
Re: Recommended way to redirect server IP to Domain?[Self Solve]
  • Quote

Post by mailarn » Tue Feb 26, 2019 4:11 pm

Please look: https://www.htaccessredirect.net/index.php

Everything must be written in the file .htaccess

Example:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^YOUR SITE[nc]
RewriteRule ^(.*)$ http://www.YOUR SITE/$1 [r=301,nc]

RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

YOUR SITE - change to your

good luck
Top

adamjedgar
Posts: 43
Joined: Tue Apr 18, 2017 7:55 am

Re: Recommended way to redirect server IP to Domain?[Self Solve]
  • Quote

Post by adamjedgar » Sat Jun 01, 2019 10:04 pm

Of course remember htaccess doesn't work with standalone nginx
Top

pawelcnet
Posts: 11
Joined: Fri Jul 15, 2016 8:16 pm
Contact:
Contact pawelcnet
Website

Os: Ubuntu 15x
Web: apache + nginx
Re: Recommended way to redirect server IP to Domain?[Self Solve]
  • Quote

Post by pawelcnet » Fri Jan 24, 2020 7:11 pm

create 2 files in /usr/local/vesta/data/templates/web/nginx/

redirect.tpl

Code: Select all

server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    location / {
         return 301 https://%proxy_extentions%;
   }
   
   include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
}
redirect.stpl

Code: Select all

server {
    listen      %ip%:%proxy_ssl_port%;
    server_name %domain_idn% %alias_idn%;
	ssl         on;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
	
    location / {
         return 301 https://%proxy_extentions%;
   }
   
   include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
}
How to use

In domain edit in Proxy Support -> Proxy Template select "redirect" and in Proxy Extensions type one domain without http or https just "somedomian.com" so your domain will redirect to "somedomian.com"
Top

delight
Posts: 1
Joined: Mon Apr 27, 2020 9:34 pm

Os: Debian 8x
Web: nginx + php-fpm
Re: Recommended way to redirect server IP to Domain?[Self Solve]
  • Quote

Post by delight » Tue Apr 28, 2020 8:45 pm

pawelcnet wrote: ↑
Fri Jan 24, 2020 7:11 pm
create 2 files in /usr/local/vesta/data/templates/web/nginx/
...
Thank you for this suggestion!

Could you pls let me know how to redirect server ip to domain using nginx + php-fpm ?
There is no Proxy Support option in domain edit...
Top


Post Reply
  • Print view

8 posts • Page 1 of 1

Return to “Modification & Patches”



  • 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