Page 2 of 2

Re: Forward ip to domain - SSL

Posted: Tue May 12, 2015 7:20 pm
by skurudo
hafeezksa wrote: Where to keep this .htaccess file ?
In your domain folder..

/home/user/web/yourdomain.tld/public_html

Re: Forward ip to domain - SSL

Posted: Tue May 12, 2015 8:24 pm
by hafeezksa
skurudo wrote:
hafeezksa wrote: Where to keep this .htaccess file ?
In your domain folder..

/home/user/web/yourdomain.tld/public_html
Actually I want to redirect my VPS IP to a domain name I did it in /usr/local/vesta/nginx/conf/nginx.conf
It is ok when I use https+IP, it redirecting to my ssl site, but when I use http+IP without ssl it is redirecting to my an other domain (without ssl). I want to redirect IP to my ssl site even with http or https, how to do that ?

Re: Forward ip to domain - SSL

Posted: Wed May 13, 2015 5:44 am
by skurudo
hafeezksa wrote:Actually I want to redirect my VPS IP to a domain name I did it in /usr/local/vesta/nginx/conf/nginx.conf
It is ok when I use https+IP, it redirecting to my ssl site, but when I use http+IP without ssl it is redirecting to my an other domain (without ssl). I want to redirect IP to my ssl site even with http or https, how to do that ?
There already is recipe how to
https://vestacp.com/docs/#how-to-force-https

Re: Forward ip to domain - SSL

Posted: Wed May 13, 2015 12:00 pm
by hafeezksa
skurudo wrote:
hafeezksa wrote:Actually I want to redirect my VPS IP to a domain name I did it in /usr/local/vesta/nginx/conf/nginx.conf
It is ok when I use https+IP, it redirecting to my ssl site, but when I use http+IP without ssl it is redirecting to my an other domain (without ssl). I want to redirect IP to my ssl site even with http or https, how to do that ?
There already is recipe how to
https://vestacp.com/docs/#how-to-force-https
With ssl doamin there is no any problem its ok. Actually, I want to redirect my vps ip to my https site for example if I use this IP URL
http://192.168.1.10 it should redirect to my domain https://mydoamin.com
http://192.168.1.10 (not working) ?
https://192.168.1.10 (working and redirecting ok)

Re: Forward ip to domain - SSL

Posted: Wed May 13, 2015 12:25 pm
by skurudo
Try something like this in /etc/nginx/conf.d/yourip.conf

Code: Select all

error_page      497 https://mydoamin.com;

Re: Forward ip to domain - SSL

Posted: Thu May 14, 2015 4:43 pm
by hafeezksa
skurudo wrote:Try something like this in /etc/nginx/conf.d/yourip.conf

Code: Select all

error_page      497 https://mydoamin.com;
I add this code after restarting vesta service, I am not able to start vesta service even I remove this code from conf file.
There is error as below:
# service vesta start
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED]
How to fix this problem?

Re: Forward ip to domain - SSL

Posted: Sun May 17, 2015 4:51 pm
by skurudo

Code: Select all

/etc/init.d/apache2 stop
/etc/init.d/nginx stop
/etc/init.d/nginx start
/etc/init.d/apache2 start
Where you exactly put this string?

Re: Forward ip to domain - SSL

Posted: Sun May 17, 2015 5:08 pm
by hafeezksa
skurudo wrote:

Code: Select all

/etc/init.d/apache2 stop
/etc/init.d/nginx stop
/etc/init.d/nginx start
/etc/init.d/apache2 start
Where you exactly put this string?
Regarding error in my above post, there was my mistake some days ago in nginx.conf I changed (under Vhost) vesta port from 8083 to 80 and I forget to return it. The problem was fixed.

Re: Forward ip to domain - SSL

Posted: Sun May 17, 2015 5:15 pm
by skurudo
hafeezksa wrote: Regarding error in my above post, there was my mistake some days ago in nginx.conf I changed (under Vhost) vesta port from 8083 to 80 and I forget to return it. The problem was fixed.
Oh, so it is ;-) Nice.

Re: Forward ip to domain - SSL

Posted: Tue Oct 06, 2015 1:09 am
by weirdaljr
hafeezksa wrote:
skurudo wrote:
hafeezksa wrote:Actually I want to redirect my VPS IP to a domain name I did it in /usr/local/vesta/nginx/conf/nginx.conf
It is ok when I use https+IP, it redirecting to my ssl site, but when I use http+IP without ssl it is redirecting to my an other domain (without ssl). I want to redirect IP to my ssl site even with http or https, how to do that ?
There already is recipe how to
https://vestacp.com/docs/#how-to-force-https
With ssl doamin there is no any problem its ok. Actually, I want to redirect my vps ip to my https site for example if I use this IP URL
http://192.168.1.10 it should redirect to my domain https://mydoamin.com
http://192.168.1.10 (not working) ?
https://192.168.1.10 (working and redirecting ok)

I was running into the same issue and I just got it to work on my VPS 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;
   }
}