Preface Because this is a distributed file system that has been deployed externally on the intranet, using fastdfs. The application is deployed to port 8088, and its backend management system is deployed on port 8089 (on the same intranet server). The service of the backend management system needs to request the fastdfs service, which can be directly requested (resources of the same server). However, we have only externalized the backend management system (Springboot project) and can only access the backend management system without using the IP allocated by the public network. To directly access the interface of the fastdfs service, you must connect to the server public network, but this limits our users' access (I can't go to your server every time to access it, I think I can access it from other places)
ProxyServlet Because the backend project port 8089 can access the server fastdfs service, my first thought is to use Springboot's ProxyServlet to proxy the specified request to the server port 8088
rely <dependency> <groupId>org.mitre.dsmiley.httpproxy</groupId> <artifactId>smiley-http-proxy-servlet</artifactId> <version>1.7</version> </dependency> Configuration ### Configure the proxy# When requesting resource, the proxy forwards to port 8088 in the project proxy.test.servlet_url_one= /resource/* proxy.test.target_url_one= https://localhost:8088 @Component @Data public class ProxyFilterServlet { @Value("${proxy.test.target_url_one}") private String targetUrl; @Value("${proxy.test.servlet_url_one}") private String servletUrl; } Change config to add @Configuration public class ProxyServletConfig { @Autowired private ProxyFilterServlet proxyFilterServlet; //Multiple proxy servlets can configure multiple beans @Bean public ServletRegistrationBean servletRegistrationBean(){ ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ProxyServlet(), proxyFilterServlet.getServletUrl()); //This setName must be set, and when there are multiple, the names need to be different servletRegistrationBean.setName("go_backend"); servletRegistrationBean.addInitParameter("targetUri", proxyFilterServlet.getTargetUrl()); servletRegistrationBean.addInitParameter(ProxyServlet.P_LOG, "false"); return servletRegistrationBean; } }
nginx—Proxy forwarding
Transfer the external network request to the same server intranet port server { listen 80; server_name 127.0.0.1; location / { proxy_pass http://127.0.0.1:3000; } location ~ /api/ { proxy_pass http://172.30.1.123:8081; } } Reference blog post: https://www.jb51.net/article/174382.htm https://www.jb51.net/article/174383.htm Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Will mysql's in invalidate the index?
>>: Detailed explanation of the implementation principles of call, apply, and bind in JavaScript
When learning about inline-block, I found that the...
The css animation of the rotating flip effect, th...
Introduction By enabling the slow query log, MySQ...
Uninstall MariaDB CentOS7 installs MariaDB instea...
Table of contents 1. Install Docker 2. Write code...
Cross-domain solutions jsonp (simulate get) CORS ...
When I was in the securities company, because the ...
Table of contents 1. What is a database? 2. Class...
Table of contents Preface What is index pushdown?...
Question: In index.html, iframe introduces son.htm...
2.1 Semanticization makes your web pages better u...
Why do we need to summarize the browser compatibi...
Virtual machines are very convenient testing soft...
As shown below: nsenter -t 1 -m -u -n -i sh -c &q...
Preface In databases such as Oracle and SQL Serve...