OverviewNginx Reverse Proxy: Reverse proxy means that the server obtains resources from one or more groups of backend servers (such as Web servers) based on the client's request, and then returns these resources to the client. The client only knows the IP address of the reverse proxy, but does not know the existence of the server cluster behind the proxy server. The role of reverse proxy
Practice Nginx reverse proxy intranet penetration 8081 portPurpose: Hide port 8081 and access port 80 by accessing port 80 Implementation stepsWe configured the API on port 8081 and deployed it successfully. Now 8081 is open to the public, so it can be accessed Take Ubuntu environment as an example $ cd /etc/nginx/ $ vim nginx.conf Configure the reverse proxy for port 8081 under the Nginx http node as follows server { listen 80 default_server; listen [::]:80 default_server; location /api/ { proxy_pass http://127.0.0.1:8081; } location /apidocs/ { proxy_pass http://localhost:8081/api/; index swagger-ui.html; error_page 404 http://localhost:8081/api/swagger-ui.html; } } After the configuration is complete, restart the Nginx service $ service nginx restart Visit http://ip/apidocs/swagger-ui.html successfully We can turn off the server security group rules, remove the 8081 port-security group rules, and log in to Alibaba Cloud to configure. Take Alibaba Cloud as an example. The same applies to other http://ip/apidocs/swagger-ui.html is still accessible http://ip:8081/api/swagger-ui.html is not accessible So far, we have achieved the purpose of nginx reverse proxy port 8081 by accessing port 80 and proxying to port 8081 Focus on understanding the Ngnix location & proxy_pass field rules Implementation method 2: Configure upstreamUnder the http node, add the upstream node upstream demo { server ip:8080; server ip:8081; } Configure proxy_pass in the location node under the server node to: http:// + upstream name location / { proxy_pass http://demo; } Nginx configuration https support## # add cnn SSL Settings ## server{ listen 443; server_name demo.com; ssl on; ssl_certificate /etc/nginx/cert/test.pem; ssl_certificate_key /etc/nginx/cert/test.key; ssl_session_timeout 5m; location / { #Root domain name or IP proxy_pass http://demo.com; } } SummarizeThis is the end of this article about the introduction to Nginx reverse proxy. For more relevant Nginx reverse proxy content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: setup+ref+reactive implements vue3 responsiveness
>>: Example code for realizing charging effect of B station with css+svg
Normally, when a deadlock occurs, the connection ...
When the data changes, the DOM view is not update...
Achieve results html <div class="containe...
This article mainly introduces the case of Vue en...
The following code is in my test.html. The video c...
Nginx is configured with the same domain name, wh...
This article example shares the specific code of ...
The <area> tag defines an area in an image ...
Operation effect html <head> <meta chars...
Vue front and back end ports are inconsistent In ...
Due to the initial partitioning of the system, th...
Let's learn about different types of loops th...
1. display:box; Setting this property on an eleme...
Introduction: The configuration of Docker running...
In the nginx process model, tasks such as traffic...