Hello, welcome toPeanut Shell Foreign Trade Network B2B Free Information Publishing Platform!
18951535724
  • Details of the use of nginx to achieve reverse agent node. Js

       2026-06-08 NetworkingName1930
    1111111
    Key Point:The company has a front end of the project where the server is rendered using node. Js and then returned to the browser to solve the soo problem on a single page. When the project was deployed, nginx was used as a reverse agent, node. Js. Specific steps are as follows:(nginx, node. Js installation and basic configuration directly skipping)First we have to open the following configuration at the http node in the nginx. Cnf file:Http {log formatmai

    The company has a front end of the project where the server is rendered using node. Js and then returned to the browser to solve the soo problem on a single page. When the project was deployed, nginx was used as a reverse agent, node. Js. Specific steps are as follows:

    (nginx, node. Js installation and basic configuration directly skipping)

    First we have to open the following configuration at the http node in the nginx. Cnf file:

    Http {
    log formatmain '$remote addr - $remote user [$time local] "$request"
    '$status $body bytes cent "$http referer"'
    '$http user age

    The configuration file for each domain name is then placed under this directory/etc/nginx/conf. D/, with the file suffix ending with a conf。

    The first, the simple:

    Server {
    80;
    name localhost;
    root /xx/xx/hxydex/;
    
    #set $my server name $scheme://$server name;
    #if ($my server name! =https://$server name) {
    # rewrite # https://$server name$request uri?
    ♪ i'm sorry ♪
    
    er          
    access log/var/log/nginx/hyde accss. Logmain;
    
    organisation
    proxy set header x-real-ip $remote addr;
    proxy set header x-for$proxy add x forwarded for;
    proxy set head host $ http host;
    proxy set header x-nginx-proxy true;
    proxy http version1. 1;
    proxy set head coNo, no, no.
    
    # no need to consider loads, no need to configure upstream nodes. Proxy pass http://127. 0. 0. 1:3000;
    ♪ i'm sorry ♪
    
    (b) error page 404/404. HTML;
    localization = /xx/xx/40x. HTML
    ♪ i'm sorry ♪
    error page 500 502, 503,504/50x. HTML;
    localization = /xx/xx/50x. HTML
    ♪ i'm sorry ♪
    ♪ i'm sorry ♪

    Second approach, taking into account load

    I'm sorry, upstream node
    server 127. 0. 0. 1:3,000;
    ♪ i'm sorry ♪
    server {
    80;
    name localhost;
    root /xx/xx/hxydex/;
    
    #set $my server name $scheme://$server name;
    #if ($my server name! =https://$server name) {
    # rewrite # https://$server name$request uri?
    ♪ i'm sorry ♪
    
    er          
    access log/var/log/nginx/hyde accss. Logmain;
    
    organisation
    proxy set header x-real-ip $remote addr;
    proxy set header x-for$proxy add x forwarded for;
    proxy set head host $ http host;
    proxy set header x-nginx-proxy true;
    proxy http version1. 1;
    proxy set head coNo, no, no.
    
    # configureupstream node
    proxy pass http://node;
    ♪ i'm sorry ♪
    
    (b) error page 404/404. HTML;
    localization = /xx/xx/40x. HTML
    ♪ i'm sorry ♪
    error page 500 502, 503,504/50x. HTML;
    localization = /xx/xx/50x. HTML
    ♪ i'm sorry ♪
    ♪ i'm sorry ♪

    Then you can restart or reload the nginx profile. The order reads as follows:

    #check if nginx profile is correct
    i don't know.
    # restart nginx
    i don't know.
    # reload profile
    i don't know

    Questions noted:

    Whether the proxy is seo

    The following problems may arise:

    It's not like i'm going to be able to do this.
    / unhandled 'error' event
    yeah. Error: listen to eaddrinuse
    (net. Js: 884:11)
    listen2 (net. Js:1022:14)
    at listen (net. Js: 1044:10)
    at server. Listen (net. Js:1110:5)
    i don't know, at object.(foldername/app. Js:33:24)
    (module. Js: 456:26)
    (module. Js: 474:10)
    at modeule. Load (module. Js: 356:32)
    (module. Js: 312:12)
    at function. Module. Runmain

    This is actually an error caused by the occupation of the node. Js service multi-starter, a problem that could arise by using the node. Js project management tool pm2 or using the netstat-anop to view the port occupied by that process and then kill the restart service

    Add a load balance strategy for nginx:

    Rotation (default)

    Each request is assigned in chronological order to a different backend server, which can be automatically eliminated if the backend server down。

    I'm sorry, upstream backserver
    server 192. 168. 0. 14;
    server 192. 168. 0. 15;
    ♪ i'm sorry ♪

    Assign weight

    Whether the proxy is seo

    Specifies the probability of a rotation, which is proportional to the ratio of access, for the back-end server performance。

    I'm sorry, upstream backserver
    server 192. 168. 0. 14 weight = 10;
    server 192. 16. 8. 15 weight = 10;
    ♪ i'm sorry ♪

    Ip binding ip hash

    Each request is distributed according to the hash results of the visit to ip, so that each visitor has regular access to a back-end server and can solve the problem of the session。

    I'm sorry, upstream backserver
    ip hash;
    server 192. 168. 0. 14:88;
    server 192. 16. 8. 15:80;
    ♪ i'm sorry ♪

    Fair (third party)

    Distribution of requests according to back-end server response time and response to short priority assignments。

    I'm sorry, upstream backserver
    server 192. 168. 0. 14:88;
    server 192. 16. 8. 15:80;
    i'm sorry.
    ♪ i'm sorry ♪

    Url hash (third party)

    Whether the proxy is seo

    Distributes requests according to the rash results of access to url, directing each url to the same back-end server, which is more effective when cached。

    I'm sorry, upstream backserver
    server squid 1:3128;
    server squid 2:3128;
    hash $request uri;
    hash method crc32;
    ♪ i'm sorry ♪

    Summary

    This is the full text of the article, which i hope will be of some interest to you in your studies or your work. If you have any questions, please leave a message and thank you for your support。

     
    ReportFavorite 0Tip 0Comment 0
    >Related Comments
    No comments yet, be the first to comment
    >SimilarEncyclopedia
    Featured Images
    RecommendedEncyclopedia