{"id":15005,"date":"2024-03-11T11:26:11","date_gmt":"2024-03-11T07:56:11","guid":{"rendered":"https:\/\/www.itpiran.net\/blog\/?p=15005"},"modified":"2024-03-11T11:26:11","modified_gmt":"2024-03-11T07:56:11","slug":"how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application","status":"publish","type":"post","link":"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/","title":{"rendered":"How to deploy a NestJS application with Nginx on an Ubuntu VPS"},"content":{"rendered":"<h2 id=\"%d9%85%d9%82%d8%af%d9%85%d9%87\">Introduction<\/h2>\n<p>Modern web applications rely on solid, secure support. Therefore, it is essential to create applications that are scalable, secure, and architecturally complex to be managed by small and\/or large teams of developers.<\/p>\n<p>Modern developers prefer to use JavaScript on both the front-end and back-end. Express.js is a great JavaScript framework used by most developers. However, its minimal architecture makes it unsuitable for scalability and maintenance by large teams. This is where Nest.js comes in. Nest.js has a built-in architecture that makes it very suitable for scalability and deployment. Also, its native support for TypeScript makes it more suitable for developers than vanilla JavaScript.<\/p>\n<p>In this tutorial, you will learn how to deploy a NestJS application using the Nginx web server on a VPS. You will learn how to securely deploy your application to the web.<\/p>\n<h5 id=\"%d9%be%db%8c%d8%b4-%d9%86%db%8c%d8%a7%d8%b2%d9%87%d8%a7\">Prerequisites<\/h5>\n<ul>\n<li>An Ubuntu 20.04+ VPS or a physical Ubuntu machine<\/li>\n<li>Node.js and the npm (or yarn) package manager.<\/li>\n<li>Nginx web server<\/li>\n<\/ul>\n<h2 id=\"%d9%85%d8%b1%d8%ad%d9%84%d9%87-1-%d8%a2%d9%85%d8%a7%d8%af%d9%87-%d8%b3%d8%a7%d8%b2%db%8c-%d9%88-%d8%a7%d8%b3%d8%aa%d9%82%d8%b1%d8%a7%d8%b1-%db%8c%da%a9-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87-nes\">Step 1 \u2013 Preparing and deploying a NestJS application<\/h2>\n<p>In this section, you will install the NestJS CLI and create a basic NestJS application, which you will learn how to deploy using Nginx in the following sections.<\/p>\n<h5 id=\"%d9%86%d8%b5%d8%a8-nestjs-cli-%d8%a8%d9%87-%d8%b5%d9%88%d8%b1%d8%aa-%d8%ac%d9%87%d8%a7%d9%86%db%8c\">Install NestJS CLI globally<\/h5>\n<p>To install NestJS CLI on your Ubuntu machine, open a terminal and type the following command.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm i -g @nestjs\/cli<\/code><\/pre>\n<\/div>\n<p>This will install the NestJS command line interface on your machine. Next, you will learn how to create a new NestJS project.<\/p>\n<h5 id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af-%db%8c%da%a9-%d9%be%d8%b1%d9%88%da%98%d9%87-%d8%ac%d8%af%db%8c%d8%af-nestjs\">Create a new NestJS project<\/h5>\n<p>NestJS now offers two ways to start a new project. You can choose the best method that suits you.<\/p>\n<p>To create a NestJS project with the CLI, type the following command.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>nest new &lt;project-name&gt;<\/code><\/pre>\n<\/div>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output? Which package manager would you \u2764\ufe0f to use? (Use arrow keys)\r\n\u276f npm \r\nyarn \r\npnpm<\/code><\/pre>\n<\/div>\n<p>Once completed, you will receive an output like the following.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>OutputCREATE node_app\/.eslintrc.js (663 bytes)\r\nCREATE node_app\/.prettierrc (51 bytes)\r\nCREATE node_app\/README.md (3340 bytes)\r\nCREATE node_app\/nest-cli.json (171 bytes)\r\nCREATE node_app\/package.json (1947 bytes)\r\nCREATE node_app\/tsconfig.build.json (97 bytes)\r\nCREATE node_app\/tsconfig.json (546 bytes)\r\nCREATE node_app\/src\/app.controller.ts (274 bytes)\r\nCREATE node_app\/src\/app.module.ts (249 bytes)\r\nCREATE node_app\/src\/app.service.ts (142 bytes)\r\nCREATE node_app\/src\/main.ts (208 bytes)\r\nCREATE node_app\/src\/app.controller.spec.ts (617 bytes)\r\nCREATE node_app\/test\/jest-e2e.json (183 bytes)\r\nCREATE node_app\/test\/app.e2e-spec.ts (630 bytes)<\/code><\/pre>\n<\/div>\n<p>This will create a new project in the current working directory. You can use instead <code>;<\/code> Provide the absolute path to another directory as well.<\/p>\n<h5 id=\"%d8%b4%d8%a8%db%8c%d9%87-%d8%b3%d8%a7%d8%b2%db%8c-%d9%82%d8%a7%d9%84%d8%a8-%d8%a7%d8%b3%d8%aa%d8%a7%d8%b1%d8%aa%d8%b1\">Starter template simulation<\/h5>\n<p>NestJS provides an alternative way to start a new project. It is a git repository that acts as a boilerplate template. You can clone that repository and start the project with the following commands.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>git clone https:\/\/github.com\/nestjs\/typescript-starter.git &lt;project-directory &gt;<\/code><\/pre>\n<\/div>\n<p>After the cloning is complete, you need to cd into the project directory and then run npm install to install the dependencies from package.json.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd &lt;project-directory&gt;\r\nnpm install<\/code><\/pre>\n<\/div>\n<p>Once the project is ready, you can start the application server using the following command:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm run start<\/code><\/pre>\n<\/div>\n<p>This will run the application at http:\/\/localhost:3000. Now, you have a basic NestJS application ready to run on localhost.<\/p>\n<h5 id=\"%d8%aa%d8%b3%d8%aa-%d8%a7%d9%be%d9%84%db%8c%da%a9%db%8c%d8%b4%d9%86\">Application testing<\/h5>\n<p>Once you have developed your application, you can run tests on it to check if it is performing as expected. NestJS provides default Jest tests that run tests on your application. You can start testing using the following command:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm run test<\/code><\/pre>\n<\/div>\n<p>This program will test you and show results similar to the following:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output&gt; node_app@0.0.1 test\r\n&gt; jest\r\nPASS src\/app.controller.spec.ts\r\nAppController\r\nroot\r\n\u2713 should return \"Hello World!\" (24 ms)\r\nTest Suites: 1 passed, 1 total\r\nTests: 1 passed, 1 total\r\nSnapshots: 0 total\r\nTime: 2.895 s\r\nRan all test suites.<\/code><\/pre>\n<\/div>\n<p>In the following section, you will learn how to deploy this NestJS application using Nginx as a reverse proxy on your web server.<\/p>\n<h2 id=\"%d9%85%d8%b1%d8%ad%d9%84%d9%87-2-%d8%aa%d9%86%d8%b8%db%8c%d9%85-nginx-%d8%a8%d8%b1%d8%a7%db%8c-%d8%ae%d8%af%d9%85%d8%aa-%d8%a8%d9%87-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87-nestjs\">Step 2 \u2013 Configure Nginx to serve the NestJS application<\/h2>\n<p>Now, we can move on to setting up a web server to host this NestJS application. We will use the reverse proxy approach. In this approach, we run our application on localhost on a specific port and then use the Nginx server to proxy any requests to the VPS public IP address or domain to the application on localhost. Using reverse proxy servers is an industry practice because it increases the security of the web server by creating a barrier between incoming requests and the backend application itself. Also, reverse proxies allow for better load management on the server, especially when the server is used to host multiple web applications.<\/p>\n<p>We install the package manager <code>pm2<\/code> We start with the one that manages the program at runtime.<\/p>\n<h5 id=\"%d9%86%d8%b5%d8%a8-pm2-process-manager\">Install pm2 Process Manager<\/h5>\n<p>You can use the following command to open the process manager. <code>pm2<\/code> Install.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm install -g pm2<\/code><\/pre>\n<\/div>\n<p>With this work <code>pm2<\/code> It is installed globally on your device.<\/p>\n<h5 id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af-%d9%be%db%8c%da%a9%d8%b1%d8%a8%d9%86%d8%af%db%8c-nginx-%d8%a8%d8%b1%d8%a7%db%8c-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87-nestjs\">Creating Nginx configuration for NestJS application<\/h5>\n<p>Now, configure Nginx to run the application. As mentioned in the prerequisite tutorial, make sure you have allowed the Nginx application for HTTP and HTTPS in your firewall. If you are using ufw firewall, you can do this by following the instructions.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>ufw enable\r\nufw allow \u2018Nginx Full\u2018<\/code><\/pre>\n<\/div>\n<p>Now, you will create a configuration block for our NestJS application. It is recommended that you create new configuration blocks for new applications rather than editing the default settings. To create the block, type the following code in your terminal.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo nano \/etc\/nginx\/sites-available\/your_domain<\/code><\/pre>\n<\/div>\n<p>Here, we have used your_domain for the application, but you will change it to the name of your application. Then in the editor, enter the following code:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>server {\r\nserver_name your_domain www.your_domain;\r\nlocation \/ {\r\nproxy_pass http:\/\/localhost:3000;\r\nproxy_http_version 1.1;\r\nproxy_set_header Upgrade $http_upgrade;\r\nproxy_set_header Connection 'upgrade';\r\nproxy_set_header Host $host;\r\nproxy_cache_bypass $http_upgrade;\r\n}\r\n}<\/code><\/pre>\n<\/div>\n<p>Now, you create a symlink that tells Nginx to look for available web applications in the sites-available folder:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo ln -s \/etc\/nginx\/sites-available\/your_domain \/etc\/nginx\/sites-enabled\/<\/code><\/pre>\n<\/div>\n<p>Also, you need to disable the default link, otherwise, nginx will redirect all requests to the default site. Use the following command to unlink.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo unlink \/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n<\/div>\n<p>Now restart the Nginx service using the following command.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo systemctl restart nginx<\/code><\/pre>\n<\/div>\n<h5 id=\"%d8%a7%d8%b3%d8%aa%d9%82%d8%b1%d8%a7%d8%b1-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87-nestjs-%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-nginx\">Deploying NestJS application using Nginx<\/h5>\n<p>Now, you will launch the pm2 package manager to manage the execution of your NestJS application. Change the working directory to your Nestjs application directory and type the following command.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>pm2 start npm --name \"your_domain\" \u2013 start<\/code><\/pre>\n<\/div>\n<p>You can run the following command to configure pm2 to run on server restart.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>pm2 startup<\/code><\/pre>\n<\/div>\n<p>Once you are done setting up the program in pm2, go ahead and save the pm2 process list with the following:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\">pm2 save<\/pre>\n<\/div>\n<p>Now, we have set the web application to run at startup and configured Nginx to reverse proxy to our application running on localhost.<\/p>\n<h5 id=\"%d8%aa%d8%b3%d8%aa-%d9%88%d8%a8-%d8%a7%d9%be%d9%84%db%8c%da%a9%db%8c%d8%b4%d9%86\">Web application testing<\/h5>\n<p>You can test the web application from your console by typing the following command.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>curl http:\/\/localhost<\/code><\/pre>\n<\/div>\n<p>Since we have set the reverse proxy to the server&#039;s IP address itself, any request to the server&#039;s public IP address, domain, or localhost request from the server will be forwarded to the application. <code>NestsJS your_domain<\/code> It is guided.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>OutputHello World!<\/code><\/pre>\n<\/div>\n<p>In the next section, you will learn to add SSL to your application, which will allow you to use the HTTPS protocol for your requests.<\/p>\n<h2 id=\"%d9%85%d8%b1%d8%ad%d9%84%d9%87-3-%d8%a7%d9%81%d8%b2%d9%88%d8%af%d9%86-ssl-%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-lets-encrypt-%d8%a7%d8%ae%d8%aa%db%8c\">Step 3 \u2013 Add SSL using Let&#039;s Encrypt (Optional)<\/h2>\n<p>So far, you have learned how to deploy a fully functional NestJS application with the Nginx server. However, this deployment uses the HTTP protocol, which is not recommended in production due to exploit vulnerabilities. Therefore, you want to switch to the HTTPS protocol, which is an encrypted version of HTTP. HTTPS uses SSL\/TLS certificates issued by a Certificate Authority. These certificates are specific to a website and encrypt the communication between the client and the server.<\/p>\n<h5 id=\"%d9%86%d8%b5%d8%a8-certbot-cli-lets-encrypt\">Install Let&#039;s Encrypt Certbot CLI<\/h5>\n<p>Let&#039;s Encrypt provides a CLI for managing and automating SSL certificates for consumers. You can install the tool with the following command:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt install certbot python3-certbot-nginx<\/code><\/pre>\n<\/div>\n<p>This will install the certbot client on your Ubuntu VPS.<\/p>\n<h5 id=\"%d9%88%d8%a7%da%a9%d8%b4%db%8c-%da%af%d9%88%d8%a7%d9%87%db%8c%d9%86%d8%a7%d9%85%d9%87-%d9%87%d8%a7%db%8c-ssl-tls-%d8%a8%d8%b1%d8%a7%db%8c-%d8%af%d8%a7%d9%85%d9%86%d9%87-%d8%b4%d9%85%d8%a7\">Fetch SSL\/TLS certificates for your domain<\/h5>\n<p>You can now obtain SSL certificates for your domain using the following command<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo certbot --nginx -d &lt;your_domain&gt; -d &lt;www.your_domain&gt;<\/code><\/pre>\n<\/div>\n<p>You must <code>your_domain<\/code> Replace certbot with your actual domain name. If this is the first time you are running certbot on your VPS, you will be asked to enter your email and agree to the user terms. Provide the required information and continue.<\/p>\n<p>Once the certificates are installed, you can redirect all requests to HTTPS. It is recommended to redirect all requests to ensure the integrity of your website.<\/p>\n<h2 id=\"%d9%86%d8%aa%db%8c%d8%ac%d9%87\">Result<\/h2>\n<p>In this tutorial, you learned how to deploy a NestJS application using the Nginx web server on an Ubuntu VPS in production. You also learned how to set up a NestJS project and a reverse proxy for your application using Nginx. Finally, you learned how to add SSL\/TLS certificates for your server domain and ensure the integrity of communications between your clients and your server.<\/p>","protected":false},"excerpt":{"rendered":"Introduction Modern web applications rely on solid and secure support. Therefore, creating applications that\u2026","protected":false},"author":1,"featured_media":15016,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","_yoast_wpseo_canonical":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_opengraph-image":"","_yoast_wpseo_twitter-description":"","_yoast_wpseo_twitter-image":"","_yoast_wpseo_focuskeywords":"","_yoast_wpseo_primary_category":"193","footnotes":""},"categories":[193,352,204],"tags":[412,411,368],"class_list":{"0":"post-15005","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials","8":"category-app","9":"category-servers","10":"tag-application","11":"tag-nginx","12":"tag-ubuntu"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS - \u0628\u0644\u0627\u06af ITPiran<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS - \u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"og:description\" content=\"\u0645\u0642\u062f\u0645\u0647 \u0628\u0631\u0646\u0627\u0645\u0647 \u0647\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc \u0648\u0628 \u0645\u062f\u0631\u0646 \u0645\u062a\u06a9\u06cc \u0628\u0647 \u067e\u0634\u062a\u06cc\u0628\u0627\u0646 \u0645\u062d\u06a9\u0645 \u0648 \u0627\u06cc\u0645\u0646 \u0647\u0633\u062a\u0646\u062f. \u0628\u0646\u0627\u0628\u0631\u0627\u06cc\u0646\u060c \u0627\u06cc\u062c\u0627\u062f \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0647\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc \u06a9\u0647&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-11T07:56:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.itpiran.net\/2024\/03\/11112346\/Nestjs.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1793\" \/>\n\t<meta property=\"og:image:height\" content=\"1110\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\"},\"headline\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS\",\"datePublished\":\"2024-03-11T07:56:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/\"},\"wordCount\":126,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/03\\\/11112346\\\/Nestjs.jpg\",\"keywords\":[\"application\",\"nginx\",\"Ubuntu\"],\"articleSection\":[\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"\u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646\",\"\u0633\u0631\u0648\u0631\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/\",\"name\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS - \u0628\u0644\u0627\u06af ITPiran\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/03\\\/11112346\\\/Nestjs.jpg\",\"datePublished\":\"2024-03-11T07:56:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#primaryimage\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/03\\\/11112346\\\/Nestjs.jpg\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/03\\\/11112346\\\/Nestjs.jpg\",\"width\":1793,\"height\":1110},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/category\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"name\":\"\u0628\u0644\u0627\u06af ITPiran\",\"description\":\"\u0627\u062e\u0628\u0627\u0631 \u0648 \u0645\u0642\u0627\u0644\u0627\u062a \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\",\"name\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"alternateName\":\"ITPIran Blog\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"width\":512,\"height\":512,\"caption\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\",\"name\":\"admin\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/en\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Deploy a NestJS Application with Nginx on an Ubuntu VPS - ITPiran Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/","og_locale":"en_US","og_type":"article","og_title":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS - \u0628\u0644\u0627\u06af ITPiran","og_description":"\u0645\u0642\u062f\u0645\u0647 \u0628\u0631\u0646\u0627\u0645\u0647 \u0647\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc \u0648\u0628 \u0645\u062f\u0631\u0646 \u0645\u062a\u06a9\u06cc \u0628\u0647 \u067e\u0634\u062a\u06cc\u0628\u0627\u0646 \u0645\u062d\u06a9\u0645 \u0648 \u0627\u06cc\u0645\u0646 \u0647\u0633\u062a\u0646\u062f. \u0628\u0646\u0627\u0628\u0631\u0627\u06cc\u0646\u060c \u0627\u06cc\u062c\u0627\u062f \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0647\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc \u06a9\u0647&hellip;","og_url":"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/","og_site_name":"\u0628\u0644\u0627\u06af ITPiran","article_published_time":"2024-03-11T07:56:11+00:00","og_image":[{"width":1793,"height":1110,"url":"https:\/\/cdn.itpiran.net\/2024\/03\/11112346\/Nestjs.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#article","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/"},"author":{"name":"admin","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81"},"headline":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS","datePublished":"2024-03-11T07:56:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/"},"wordCount":126,"commentCount":0,"publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/03\/11112346\/Nestjs.jpg","keywords":["application","nginx","Ubuntu"],"articleSection":["\u0622\u0645\u0648\u0632\u0634\u06cc","\u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646","\u0633\u0631\u0648\u0631"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/","url":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/","name":"How to Deploy a NestJS Application with Nginx on an Ubuntu VPS - ITPiran Blog","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#primaryimage"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/03\/11112346\/Nestjs.jpg","datePublished":"2024-03-11T07:56:11+00:00","breadcrumb":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#primaryimage","url":"https:\/\/cdn.itpiran.net\/2024\/03\/11112346\/Nestjs.jpg","contentUrl":"https:\/\/cdn.itpiran.net\/2024\/03\/11112346\/Nestjs.jpg","width":1793,"height":1110},{"@type":"BreadcrumbList","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-deploy-a-nestjs-application-with-nginx-on-ubuntu-22-04-vpstesting-the-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.itpiran.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u0622\u0645\u0648\u0632\u0634\u06cc","item":"https:\/\/www.itpiran.net\/blog\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0642\u0631\u0627\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 NestJS \u0628\u0627 Nginx \u062f\u0631 Ubuntu VPS"}]},{"@type":"WebSite","@id":"https:\/\/www.itpiran.net\/blog\/#website","url":"https:\/\/www.itpiran.net\/blog\/","name":"ITPiran Blog","description":"Iranian Sustainable Trade News and Articles","publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.itpiran.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.itpiran.net\/blog\/#organization","name":"Sustainable Iranian Business Blog","alternateName":"ITPIran Blog","url":"https:\/\/www.itpiran.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","contentUrl":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","width":512,"height":512,"caption":"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81","name":"admin","url":"https:\/\/www.itpiran.net\/blog\/en\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts\/15005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/comments?post=15005"}],"version-history":[{"count":10,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts\/15005\/revisions"}],"predecessor-version":[{"id":15015,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts\/15005\/revisions\/15015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/media\/15016"}],"wp:attachment":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/media?parent=15005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/categories?post=15005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/tags?post=15005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}