Nginx Intranet Standalone Reverse Proxy Ubuntu18.04 virtual machine 1 IP: 192.168.10.10 Test purpose: Deploy Nginx server on virtual machine 1 (192.168.10.10:80), access the self-set domain name through the browser, and reverse proxy to the intranet virtual machine 2 (192.168.10.11:1234). It is best that virtual machine 2 can be accessed with a browser, and the display interface is different from Nginx, such as installing a tomcat. 1 Nginx InstallationVirtual machine 1 is used as the Nginx server and is installed as follows: sudo apt-get install build-essential sudo apt-get install libtool sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev sudo apt-get install zlib1g-dev sudo apt-get install openssl sudo apt-get update sudo apt-get install nginx Run the systemctl status nginx command to verify whether the installation is successful. $ systemctl status nginx ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en Active: active (running) since Mon 2021-11-01 10:07:38 CST; 4h 19min ago Docs: man:nginx(8) Main PID: 8915 (nginx) Tasks: 3 (limit: 9461) CGroup: /system.slice/nginx.service ├─8915 nginx: master process /usr/sbin/nginx -g daemon on; master_pro ├─8916 nginx: worker process └─8917 nginx: worker process ... 2 Configure NginxVirtual Machine 1: /etc/nginx/nginx.conf is the main configuration file. I haven't studied it in detail, but be sure to uncomment the following content: include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; After modification, restart Nginx with service nginx restart. Create /etc/nginx/conf.d/test.conf as follows: server { listen 80; #Nginx server listening port charset utf-8; server_name test.com; #Domain name location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_pass http://192.168.10.11:1234/; #reverse proxy IP+port proxy_redirect off; } } In the proxy_pass http://192.168.10.10:1234/; line, don’t forget to add the final slash ‘/’. nginx -s reload updates the configuration The principle of reload: 3 Modify the hosts fileVirtual machine 1 adds the following to the /etc/hosts file: 4 TestingEnter 192.168.10.10 in the browser, and the text of Nginx is displayed. This is the Nginx effect of virtual machine 1 itself. When you enter test.com, the application content of virtual machine 2 appears, indicating that the reverse proxy is successful. This is the end of this article about the implementation of Nginx intranet stand-alone reverse proxy. For more relevant Nginx intranet reverse proxy content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: JavaScript BOM location object + navigator object + history object
>>: Solution to inserting a form with a blank line above and below
Table of contents Integrity constraints Definitio...
This article uses an example to describe how to c...
Table of contents Install Redis on Docker 1. Find...
1. Why create an index? (Advantages) This is beca...
<br />Related articles: 9 practical suggesti...
Table of contents need Core Idea Two ways to impl...
Table of contents I. Definition 2. Usage scenario...
Methods for changing passwords before MySQL 5.7: ...
Table of contents Select Structure Loop Structure...
As a front-end monkey, whether it is during an in...
Written in front Nginx is not just a reverse prox...
Table of contents Preface The role of deconstruct...
Dynamic rem 1. First, let’s introduce the current...
Preface Engineers working in the Linux environmen...
Syn attack is the most common and most easily exp...