Conjecture caused by the Jexus web server deployment. NetCore and port Analysis in ubuntu16.04-x64 system !, Jexusnetcore

Source: Internet
Author: User

Conjecture caused by the Jexus web server deployment. NetCore and port Analysis in ubuntu16.04-x64 system !, Jexusnetcore
Do you have such complaints?

I haven't updated my blog for a week. I just want to talk about what I am doing. The main reason is that the company has arranged interfaces for a large travel company, and the number of interfaces is about 10, after the connection, you still need to add it to the business system and the App, so it takes some time. In terms of time, the business needs should be put online in the last week of January, June, and the entire three weeks, I am solely responsible for this. Since I took over another company interface before, I have already set up the overall architecture and provided the interface to the app, so I am mainly responsible for connecting to a company interface, as for the details, the system should be changed to the back-end system, and the data format should be almost the same; as for my development proficiency, it can be basically done in one week, and the rest of the time will be tested, drinking tea, learn about it. Who knows... Because the interface documentation is incomplete, almost every Technology is responsible for one or two interfaces (yes, this is a big company, so detailed ), in addition, if you have any questions, the response is slow during qq consultation (maybe others are busy). On the Friday of the first week, the test results of the app and the interface are almost all completed. (I can embed an interface into the business, so I can test the app directly ), who knows that an exception occurred during the second week, that is, on Tuesday of this week when I tried to place an order for multiple people. Then I contacted the other party and was notified that the Order interface was not the latest, however, the other interfaces are the latest. We will wait for a while for the latest order interface to go online; at this time, I was speechless (who told you that you are a big company), which is a waste of "enthusiasm" for my connection and consulting ";

Preparations before deployment

Start to get started here. First, prepare the ubuntu System (I will write a separate article about how to install ubuntu in OracleVM and the precautions). Here I am from 16.04 to x64, why do I need to specify the version number, because after I download the latest Jexus package on the official website, it is impossible to run it. Later, I found an address in my article, after the installation and test run, the latest version can also be marked, but a 64-bit mark is followed, which is a miserable day;

We also need a. netcore program. For testing convenience, I created an api program and modified it in the api action as follows:

1 [HttpGet] 2 public IEnumerable <string> Get () 3 {4 return new string [] {$ "this site is: {Request. host. host }:{ Request. host. port} "}; 5}

Output the ip address and port corresponding to the current application, because the code in Program. cs is also modified for better testing and differentiation:

1 public static void Main (string [] args) 2 {3 var builder = new WebHostBuilder () 4. useKestrel (); 5 // The parameter specifies port 6 builder = args. length> 0? Builder. useUrls (args [0]): builder; 7 var host = builder. useContentRoot (Directory. getCurrentDirectory () 8. useIISIntegration () 9. useStartup <Startup> () 10. useApplicationInsights () 11. build (); 12 host. run (); 13}

After the code is changed, you need to generate the running package. If you are interested, you can check it here.Asp. NetCore1.1 does not have project. json, so as to generate cross-platform packagesAnd then upload the package to the Virtual Machine in multiple ways. Here I transfer the package through the shared directory. If you have a friend who needs it, you can share it with me;

The rest is to use the Jexus web server Service in ubuntu. For the sake of my virtual machine space, here I operate in tmp. The main steps are as follows to open the terminal:

1. cd/tmp (enter the temporary directory)

2. wget linuxdot.net/down/jexus-5.8.2-x64.tar.gz (download the jexus file package)

3. tar zxvf jexus-5.8.2-x64.tar.gz (unzip to the current directory without installation)

4. chmod o + w/tmp/jexus/siteconf (you can directly set the siteconf configuration folder in the jexus folder)

5. chmod o + w/tmp/jexus/siteconf/default)

6. cd jexus (enter the jexus directory. Note: if you follow the steps below, you can directly access the jexus directory. The actual jexus directory is in cd/tmp/jexus)

7 .. /jws start (to test whether jexus can run normally, when I write this blog, the result returned by executing this command for the first time is: Failure, because I didn't use the root permission to execute the command, change to root to execute the command. Why do you have the opportunity to talk about it later)

 

Jexus web server deployment started. NetCore

First, you can directly click the folder to enter the following directory (you can also access it through the terminal, which is convenient for your personal interests):/tmp/jexus/siteconf; you can see the file named "default, this file is not read-only with the root permission during installation, because we use the command above: chmod o + w/tmp/jexus/siteconf/default users who have set other permissions can modify the content, so I will change the content directly here. Other information will not be changed for the time being, you only need to add the apphost node:

1 port = 802 root = // var/www/default3 hosts = * # OR your.com ,*. your. com4 # Add an apphost node 5 AppHost = {export line = dotnet/home/wangrudong003/netcore/publish01/T_Jexus.dll; AppRoot =/home/wangrudong003/netcore/publish01; Port = 5000}

Several attributes of the apphost node are added:

CmdLine: Execute the command. A friend running netcore may know that ,. netcore can run the following command: dotnet xxx. dll can run the program in this way. Similarly, it can be seen as the same, but you need to specify the specific directory of the application. Here I am/home/wangrudong003/netcore/publish01)
AppRoot: indicates the application directory. Here I am/home/wangrudong003/netcore/publish01
Port: listening Port;

 

Jexus note (you can go here for details: https://www.linuxdot.net/bbsfile-3084 ):
Port = 80: Indicates listening to port 80 through jexus to access our/home/wangrudong003/netcore/publish01/T_Jexus.dll Program
Root = // var/www/default: Specifies the virtual directory

Finally, enter the directory cd/tmp/jesux with the root permission, and then enable the Service:./jws start. If no exception occurs, you can also see the following information:

Then we can access the following deployed interfaces through port 80 (My ubuntu Server ip address is 172.16.9.66): http: // 172.16.9.66/api/values. The access is successful:

 

Analyze whether the Port in AppHost configuration works.

In some tests, we can see that port 80 can normally access our interface site. Now we can use the linux Command to view the listening port on the server and the tcp listening port command: sudo netstat-lntp, which can be cast

The figure shows port 80 listened by the jexus service and port 5000 executed by the dotnet command. To better test the port function of the apphost, we need to change the port in the default file to port 5000 to port 5001 for testing. After the configuration is changed:

1 AppHost={CmdLine=dotnet /home/wangrudong003/netcore/publish01/T_Jexus.dll;AppRoot=/home/wangrudong003/netcore/publish01;Port=5001}

Restart the jexus service and run the following command:./jws restart:

After the restart, we can access http: // 172.16.9.66/api/values again. At this time, we cannot access the interface:

Although our jexus server is in the OK status, but the interface is no longer accessible, let's take a look at the listening port:

Port diagram comparison and analysis

In this comparison with the previous port, we can find that port 5000 is still executed by dotnet, which is a little strange because it does not match the port: 5001 of the configuration file we modified, in this case, we can boldly guess that the port setting of jexus is ineffective. In the end, port 5000 should be the default port that comes with dotnet;

Question

However, we are wondering why port 80 published by jexus cannot access the api if port 5000 is okay, is it because the port: 5001 of the jexus we set does not correspond to port 5000 of the actual listening port? To test the configuration of the AppHost, modify the configuration information of the AppHost again:

AppHost={CmdLine=dotnet /home/wangrudong003/netcore/publish01/T_Jexus.dll http://127.0.0.1:5001;AppRoot=/home/wangrudong003/netcore/publish01;Port=5001}

This time, we set the port for the netcore listener according to the netcore Command Format: dotnet xxx. dll http: // 127.0.0.1: 5001.Program. csThe reason for the code in is to test the conjecture. After the modification, run the jexus service command:./jws restart. Run the OK command to access the port 80 interface first:

Now we can access our interfaces normally. The best thing to verify is to check the listening port:

Comparison between the second and third port charts

Through the third-party figure above, we can see that the netcore program is bound with port 5001 at this time. At this time, port 80 opened by jexus can also access our interfaces normally, the port: 5001 in the apphost node in the defaut file of jexus must be consistent with the port listened by dotnetcore itself. If jexus port is 8080, the netcore listening port must also be 8080, so that we can access the port through the address opened by jexus. Now, this article is over, I hope this will help you and help you a lot.Thumb ups and recommendationsThank you !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.