Home > Backend Development > PHP Tutorial > nginx reverse proxy deployment nodejs nginx reverse proxy nodejs nodejs framework nginx proxy nodej

nginx reverse proxy deployment nodejs nginx reverse proxy nodejs nodejs framework nginx proxy nodej

WBOY
Release: 2016-07-29 08:49:24
Original
1438 people have browsed it

In the node development stage, the http module is generally used to start a local server for easy debugging.
It probably looks like this:

<code><span>var</span> http = <span>require</span>(<span>"http"</span>);
<span>var</span> server = http.createServer();
server.listen(<span>8888</span>);</code>
Copy after login

Then the question is, my application has been formed, how should I deploy it to vps? You can’t use it againhttp://10.88.77.66:8888 Come and visit, right? Yes the title of the article is the solution.

My environment is roughly like this centos 6 using lnmp one-click deployment. As for how to operate lnmp, I won’t write about it. Google by yourself

Suppose my domain name is money.ivan.com I want to proxy it to http://10.88.77.66:8888, then modify the nginx config file of the corresponding domain name

<code>upstream nodejs {
    server <span>127.0</span><span>.0</span><span>.1</span>:<span>8888</span>;
    <span>#server</span><span>127.0</span><span>.0</span><span>.1</span>:<span>8888</span>;
    keepalive <span>64</span>;
}

server {
    listen <span>80</span>;
    server_name money<span>.</span>ivan<span>.</span>com;
    access_log  /home/wwwlogs/money<span>.</span>ivan<span>.</span>com<span>.</span><span>log</span>  access;
    location <span>/</span> {
        proxy_set_header X<span>-Real</span><span>-IP</span><span>$remote_addr</span>;
        proxy_set_header X<span>-Forwarded</span><span>-For</span><span>$proxy_add_x_forwarded_for</span>;
        proxy_set_header Host  <span>$http_host</span>;
        proxy_set_header X<span>-Nginx</span><span>-Proxy</span><span>true</span>;
        proxy_set_header Connection <span>""</span>;
        proxy_pass      http:<span>//nodejs;</span>    }

}</code>
Copy after login

through the above modifications , make nginx reverse proxy to our site. You can access our application through money.ivan.com.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the nginx reverse proxy deployment of nodejs, including the content of NodeJS and nginx. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template