A cloud container is a type of product based on cloud computing that the service provider, by creating hardware facilities and some tools, increases the speed of software development and solves the developer’s concern related to the required infrastructure of the product.
This guide discusses how to set up a custom domain to use in the ArvanCloud container.
Prerequisite
Custom Domain Setting through the User Panel
The guide for using Route in the ArvanCloud container service explained how to send HTTP and HTTPS requests to the application through Route. This article will describe how to use your custom domain and set it up for the application in the ArvanCloud container service. The main prerequisite for using this feature is to transfer a domain to ArvanCloud DNS.
After transferring your domain, you need to create a record for the domain name you plan to put on your app.
This record should be of ANAME type for the root of the domain and CNAME type for a subdomain, and the value “default-gateway.ir-thr-ba1.arvan.run” should be set, and the cloud icon should be on.
Note that the cloud symbol of this record must be active. Also, the “default-gateway.ir-thr-ba1.arvan.run” value is for the Bamdad region. For regions such as Shahriar, this value is equivalent to default-gateway.ir-tbz-sh1.arvan.run. (This region is currently not active)
Then, in the cloud container menu, click on the desired application from the list of applications, and in the “Domain” section, activate the Custom Domain feature. Enter your domain’s or subdomain’s name in the domain field and use HTTPS activation if desired. Applying these settings creates the Route needed for your application, and your Custom Domain is set on your desired application.
Setting Custom Domain through Command Line
In the training article on creating Route, complete information about how to make and use Route was said. However, if you need to set your custom domain without applying settings in the user panel and through the command line, you must create the appropriate Route for your application. For example, to set a custom domain using the command line, it is enough to define a Route and enter your desired domain or subdomain in the Host section:
Note: Indentation in YAML files is important, and the slightest shift can cause an error or unwanted settings to be returned.
The relevant fields are explained below:
kind: specifies the nature type. This field can have values such as Pod, Route, Service, StatefulSet, etc. In this example, the target of the route definition is that this value is specified.
metadata.name: Specifies the name of the Route.
spec.host: Specifies the domain through which requests can be sent to the Route from outside the ArvanCloud cloud container. Note that the inserted value is equivalent to the record you set.
spec.to: Specifies the entity to which requests should be directed. In this example, requests are sent to the nginx service.
spec.tls: In this section, necessary information for tls termination is placed.
spec.tls.termination: This field specifies how the termination should be. Allowed values for this field are edge, passthrough, and reencrypt, which are explained in this article.
spec.tls.insecureEdgeTerminationPolicy: Insecure (http) traffic is not allowed by default. By setting spec.tls.insecureEdgeTerminationPolicy to Allow, insecure traffic will also pass through the Route.
spec.port.targetPort: Note that Route can only send traffic to a Port defined in Service. By default, the Route sends traffic to the Port specified earlier in the service definition. However, if you need to send traffic to a specific service port, you can use this field to assign a port to send traffic.
Enter and save the above lines in a file called nginx-route.yaml. Then submit your Route to the ArvanCloud Cloud Container through the command line with the following command.
Then, with the following command, you can know the status of your Route and its execution on the ArvanCloud Cloud Container.
The output will be similar to the following:
Note, since you have activated the cloud icon for your record, and traffic from Route is sent to your application as HTTP, there is no need to provide a certificate, and with the said settings, you can also use HTTPS traffic to send requests to use your application.