Home >Backend Development >PHP Tutorial >nginx reverse proxy deployment nodejs nginx reverse proxy nodejs nodejs framework nginx proxy nodej
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>
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>
through the above modifications , make nginx reverse proxy to our site. You can access our application through money.ivan.com
.
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.