We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Recommended way to redirect server IP to Domain?[Self Solve]
Recommended way to redirect server IP to Domain?[Self Solve]
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?
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.
Re: Recommended way to redirect server IP to Domain?
Has anyone been able to do this with Vesta?
Re: Recommended way to redirect server IP to Domain?
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
/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;
}
}
Re: Recommended way to redirect server IP to Domain?[Self Solve]
I know is way later,but I can confirm that is working on CentOS 7 too, same 1 IP, VPS.
Re: Recommended way to redirect server IP to Domain?[Self Solve]
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
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
-
- Posts: 43
- Joined: Tue Apr 18, 2017 7:55 am
Re: Recommended way to redirect server IP to Domain?[Self Solve]
Of course remember htaccess doesn't work with standalone nginx
Re: Recommended way to redirect server IP to Domain?[Self Solve]
create 2 files in /usr/local/vesta/data/templates/web/nginx/
redirect.tpl
redirect.stpl
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"
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;
}
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;
}
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"