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.
Forward ip to domain - SSL
-
- Posts: 54
- Joined: Wed Dec 11, 2013 9:05 pm
Forward ip to domain - SSL
Hello I updated VestaCp with new ssl certificates but they don't work with my ip only with my domain. So I have been playing with everything to make VestaCp rewrite or forward to my domain but I cant find a way to do it. I tried adding .htaccess and editing the nginx file but nothing seams to work can someone please help me with this?
aaa.bbb.ccc.ddd -> https://www.example.com
aaa.bbb.ccc.ddd -> https://www.example.com
-
- Posts: 54
- Joined: Wed Dec 11, 2013 9:05 pm
Re: Forward ip to domain - SSL
This seems to work in /usr/local/vesta/web/index.php
The only issue is you will have to do this for every /dir/ I cant find where to edit this globally.
.htaccess doesn't work I tried editing /usr/local/vesta/nginx/conf/nginx.conf but when I do a rewrite in there it doesn't work.
Code: Select all
$redirect = 'www.domain.com:'.$_SERVER['SERVER_PORT'];
if ($_SERVER['HTTP_HOST'] != $redirect) {
header("Location: https://$redirect/");
exit;
}
.htaccess doesn't work I tried editing /usr/local/vesta/nginx/conf/nginx.conf but when I do a rewrite in there it doesn't work.
-
- Posts: 54
- Joined: Wed Dec 11, 2013 9:05 pm
Re: Forward ip to domain - SSL
Ok so apparently I wasn't writing the correct nginx code.
All you have to do is edit the above mentioned nginx.conf
if ($http_host !~* ^(www\.)?example.com:8083$) {
rewrite ^(.*)$ https://www.example.com:8083$1 permanent;
}
that will fix the issue :)
All you have to do is edit the above mentioned nginx.conf
if ($http_host !~* ^(www\.)?example.com:8083$) {
rewrite ^(.*)$ https://www.example.com:8083$1 permanent;
}
Code: Select all
# Vhost
server {
listen 8083;
server_name _;
root /usr/local/vesta/web;
charset utf-8;
ssl on;
ssl_certificate /usr/local/vesta/ssl/certificate.crt;
ssl_certificate_key /usr/local/vesta/ssl/certificate.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 404 /error/index.html;
error_page 403 /error/index.html;
error_page 500 /error/index.html;
if ($http_host !~* ^(www\.)?example.com:8083$) {
rewrite ^(.*)$ https://www.example.com:8083$1 permanent;
}
location / {
expires max;
index index.php;
}
...
Re: Forward ip to domain - SSL
dont use IF
http://wiki.nginx.org/IfIsEvil
use this
http://wiki.nginx.org/IfIsEvil
use this
Code: Select all
server {
listen 8083 default_server;
server_name _;
return 301 https://example.com$request_uri;
}
server {
listen 8083;
server_name example.com;
root /usr/local/vesta/web;
charset utf-8;
ssl on;
ssl_certificate /usr/local/vesta/ssl/certificate.crt;
ssl_certificate_key /usr/local/vesta/ssl/certificate.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
...
-
- Posts: 54
- Joined: Wed Dec 11, 2013 9:05 pm
Re: Forward ip to domain - SSL
Thanks for your suggestion i went ahead and used the following:
This makes VestaCP use HTTPS, adds WWW and forwards direct ip to your domain.
Code: Select all
server {
listen 8083;
server_name _;
root /usr/local/vesta/web;
charset utf-8;
ssl on;
ssl_certificate /usr/local/vesta/ssl/certificate.crt;
ssl_certificate_key /usr/local/vesta/ssl/certificate.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 404 /error/index.html;
error_page 403 /error/index.html;
error_page 500 /error/index.html;
error_page 497 https://$host:$server_port$request_uri;
if ($host !~* ^www(.*)) {
return 301 https://www.example.com:$server_port$request_uri;
}
location / {
expires max;
index index.php;
}
-
- Posts: 54
- Joined: Wed Dec 11, 2013 9:05 pm
Re: Forward ip to domain - SSL
add the following after the above if question to force only one domain for vestacp:
Code: Select all
if ($host !~* ^www\.example\.com$) {
return 301 https://www.example.com:$server_port$request_uri;
}
-
- Posts: 30
- Joined: Sun Nov 23, 2014 4:41 am
Re: Forward ip to domain - SSL
Not working for me...
This webpage is not available
-
- Posts: 8
- Joined: Fri Apr 03, 2015 10:18 pm
Re: Forward ip to domain - SSL
.htaccess worked for me :) i will later post the exact code :)
Re: Forward ip to domain - SSL
Something like this, I think.donkfather wrote:.htaccess worked for me :) i will later post the exact code :)
Code: Select all
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Re: Forward ip to domain - SSL
Where to keep this .htaccess file ?skurudo wrote:Something like this, I think.donkfather wrote:.htaccess worked for me :) i will later post the exact code :)
Code: Select all
#First rewrite any request to the wrong domain to use the correct one (here www.) RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] #Now, rewrite to HTTPS: RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]