1

I have a website.example.com The website is hosted on OVH I would like to point a sub domain shop.example.com to another website hosted on another server (95.110.189.135:8069) the problem is that I can't c name to an IP with a port. I used Ubuntu for my odoo server

I've got odoo on my vps server with database. Now, It's working on IP with port (example: 55.55.55.55:8069). So now,

How can I change it to IP without port?

If I want a domain name - how can I do this?

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Boubaker
  • 427
  • 1
  • 7
  • 24
  • Possible duplicate of [\*.mydomain.com - A record or CNAME?](https://stackoverflow.com/questions/2861372/mydomain-com-a-record-or-cname) – arirawr Apr 16 '18 at 10:39
  • 1
    You can't specify a port within DNS. You would need a redirect or something else to take users from port 80 to 8096. This also looks off topic here as its not a programming question. You should try [serverfault](https://serverfault.com) or [superuser](https://superuser.com) – user3788685 Apr 16 '18 at 16:49
  • @user3788685 you can specify ports in the DNS, see the `SRV` record type. It is just that some applications, and unfortunately browsers are in this case, are just not using them at all and hardcoding 80/443 instead. – Patrick Mevzek Apr 17 '18 at 19:10
  • @PatrickMevzek That's very true, but as you say browsers can't/don't so I didn't want to muddy the water. It might have given the OP a route of investigation that wasn't going to help in there situation, but correct to point out `SVR` records do allow for port definitions. – user3788685 Apr 17 '18 at 19:23
  • @user3788685 so you could have said "You can't specify a port within DNS in a way that browsers will pick it up" ;-) – Patrick Mevzek Apr 17 '18 at 19:30

2 Answers2

0

You cannot use plain DNS to transfer traffic to another port. This is not possible with either canonical name (CNAME record) or address (A record). These DNS services are only used for address resolution.

To solve your configuration issue you can use reverse proxy, e.g. Nginx. You can find example configurations from the Odoo.com site at https://www.odoo.com/documentation/11.0/setup/deploy.html#https. This is describing how to use https in port 443 to proxy Odoo in upstream service at port 8069. For public services you should use encrypted https, not http. Point your show.example.com in DNS to your "another" server ip address and on that server have Odoo and Nginx running. Your Odoo can run on port 8069 and your Nginx would run on https 443 and proxy connections to Odoo upstream service on localhost 8069.

Hope this helps you forward. Please check your configuration with someone who have experience with this kind of setups before you go production. This will make sure your configuration is secure.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
Veikko
  • 3,372
  • 2
  • 21
  • 31
  • `ANAME` is not a standard DNS record type. This is from some providers only. – Patrick Mevzek Apr 17 '18 at 19:34
  • Thanks for feedback Patrick. You are right. I meant plain old standard A record but wrote incorrectly. I updated the answer to be in line with standard dns records. The actual answer is still that the DNS is not the right solution. It is best practice to have a reverse-proxy and it can point to any port. – Veikko Apr 18 '18 at 05:48
0

I found the solution it's easy to redirect to port 80

to do that add a line of code in the file

etc/rc.local

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8069

then the file will become like this

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8069
exit 0

save and then restart the server

Boubaker
  • 427
  • 1
  • 7
  • 24