Alibaba Cloud Linux's nginx configures uni-app's H5 front-end project vue, and the back-end interface is Alibaba Cloud.

background

The vue project calling interface is from Alibaba Cloud, and the H5 website must also be deployed to Alibaba Cloud. Two different servers require nginx deployment and api proxy.

1.Port configuration

The first step is of course to buy an Alibaba Cloud server. Here is the configuration of the Linux system, configure the domain name to be accessed, and then:

Configure the required ports for the website as follows:

After configuration, the terminal specifies the corresponding port number to open, refer to:

After configuring the port number of the Alibaba Cloud server and opening a new port on the Alibaba Cloud web page, I restarted the firewall and the port was not activated_Lan.W's Blog-CSDN Blog  I use 8083 here

firewall-cmd --zone=public --add-port=8083/tcp --permanent  

2.nginx server installation and configuration

After downloading the nginx source code and compiling it, configure the site information in /usr/local/nginx/nginx.conf

 Configured site and api proxy on nginx 

Place the website directory:

It's ready to run. 

Whether it is a domain name website accessing the back end of the domain name format, it can be happily processed and run through nginx.


3. Sub-website linked to domain name 

Access path: http://xx.xx.com/cloudh5  

Hbuilder packaging: basic running path configuration of h5: /cloudh5

 Copy all files in the packaged h5 directory to html/cloudh5 under nginx

nginx configuration:

    location /cloudh5 {
            root   /usr/local/nginx/html;
            index  index.html index.htm;
        }

}

 The api interface proxy is still the same, no need to change, the basic running path configuration according to ./ is the same.

Guess you like

Origin blog.csdn.net/LlanyW/article/details/132920722