Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the custom domain of the aliyun log server does not work

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you what to do if the custom domain of the aliyun log server does not work. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. problem

This code does not work when you want to use aliyun sdk to send logs to an aliyun log server with a custom domain. After looking at the nodejs sdk source code, I found that the API domain was built:

Var hostname = req.httpRequest.endpoint.hostname;var projectName = req.params ['projectName']; var host = projectName+'.'+ hostname;if (! / ^ [0-9.] + $/ .test (hostname)) {/ / is not an ip, but is a domain name, so you need to concatenate the project name var protocol = req.httpRequest.endpoint.protocol; var port = req.httpRequest.endpoint.port; / / real endpoint var endpointObj = parseURL (protocol+'//'+host+':'+port) ALY.util.update (req.httpRequest, {endpoint: endpointObj}); / / ALY.util.update (req.service, {endpoint: endpointObj});}

The endpoint also has a project name prefix. This will result in incorrect address resolution.

two。 Solution

Add two address resolution rules, and the endpoint also has a project name prefix. This will result in incorrect address resolution.

Add two address resolution rules:

Machine recordrecord typerecord value@CNAMEcn-beijing.log.aliyuncs.comprojectNameCNAMEprojectName.cn-beijing.log.aliyuncs.com

Log aliyuncs. Com: we need to replace the domain with a custom field. In the second rule, the project name is the subdomain and the resolved address is the aliyun raw log service domain. If you use the nslookup test: projectName. Custom com, we can find that it is OK to resolve to the correct address.

3. Testing and verification

Before testing, you should change the endpoint from cn Beijing. Log aliyuncs. Com to your custom field, for example: jimmy. In your code. I have tested the following three sdk:

Nodejsdk

Python sdk (login based on python logs)

After changing the endpoint from Ali cloud domain to custom domain, all my code will send logs to the Ali cloud log service, so the above solution is OK.

The above is what to do if the custom domain of the aliyun log server does not work. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report