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

Jul 29, 2016 am 08:49 AM
nginx nodejs

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.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to allow external network access to tomcat server How to allow external network access to tomcat server Apr 21, 2024 am 07:22 AM

To allow the Tomcat server to access the external network, you need to: modify the Tomcat configuration file to allow external connections. Add a firewall rule to allow access to the Tomcat server port. Create a DNS record pointing the domain name to the Tomcat server public IP. Optional: Use a reverse proxy to improve security and performance. Optional: Set up HTTPS for increased security.

Is there a big difference between nodejs and java? Is there a big difference between nodejs and java? Apr 21, 2024 am 06:12 AM

The main differences between Node.js and Java are design and features: Event-driven vs. thread-driven: Node.js is event-driven and Java is thread-driven. Single-threaded vs. multi-threaded: Node.js uses a single-threaded event loop, and Java uses a multi-threaded architecture. Runtime environment: Node.js runs on the V8 JavaScript engine, while Java runs on the JVM. Syntax: Node.js uses JavaScript syntax, while Java uses Java syntax. Purpose: Node.js is suitable for I/O-intensive tasks, while Java is suitable for large enterprise applications.

How to connect nodejs to mysql database How to connect nodejs to mysql database Apr 21, 2024 am 06:13 AM

To connect to a MySQL database, you need to follow these steps: Install the mysql2 driver. Use mysql2.createConnection() to create a connection object that contains the host address, port, username, password, and database name. Use connection.query() to perform queries. Finally use connection.end() to end the connection.

How to generate URL from html file How to generate URL from html file Apr 21, 2024 pm 12:57 PM

Converting an HTML file to a URL requires a web server, which involves the following steps: Obtain a web server. Set up a web server. Upload HTML file. Create a domain name. Route the request.

What is the relationship between nodejs and npm? What is the relationship between nodejs and npm? Apr 21, 2024 am 06:09 AM

Node.js is a JavaScript runtime environment and npm is its package manager. The two work together to enable developers to write server-side programs in JavaScript, use third-party modules, and easily manage modules.

What projects is nodejs suitable for? What projects is nodejs suitable for? Apr 21, 2024 am 05:45 AM

Node.js is suitable for the following project types: Network and server applications Event-driven applications Real-time applications Data-intensive applications Command-line tools and scripts Lightweight microservices

How to connect nodejs to mycat How to connect nodejs to mycat Apr 21, 2024 am 06:16 AM

Steps to connect MyCAT in Node.js: Install the mycat-ts dependency. Create a connection pool, specify the host, port, username, password and database. Use the query method to execute SQL queries. Use the close method to close the connection pool.

How to deploy and maintain a website using PHP How to deploy and maintain a website using PHP May 03, 2024 am 08:54 AM

To successfully deploy and maintain a PHP website, you need to perform the following steps: Select a web server (such as Apache or Nginx) Install PHP Create a database and connect PHP Upload code to the server Set up domain name and DNS Monitoring website maintenance steps include updating PHP and web servers, and backing up the website , monitor error logs and update content.

See all articles