nginx one port configuration front-end and back-end separation project access

nginx one port configuration front-end and back-end separation project access

  1. nginx configuration
server {
    
    
	listen  8888;
	server_name _;
	location  ~ .*\.(gif|jpg|jpeg|png|pdf|txt|zip|rar|7z|doc|docx|xls|xlsx|ppt|pptx|mp3|mp4)$ {
    
    
       root    D:/platform/tomcat/apache-tomcat-9.0.31/webapps/resources;
    }
	location /api/ {
    
    
		proxy_pass	http://127.0.0.1:8080/; # 后台访问地址以及端口号
	}
    location / {
    
    
        root html;
        index  index.html index.htm;
     }
}
  1. Page configuration
    Insert image description here
    The IP configured on the page is the access address of the external network, such as www.baidu.com. If you use the local IP, accessing it on the server is no problem. However, when accessing the external network, there will be a problem that the backend interface request is blocked.

Guess you like

Origin blog.csdn.net/weixin_44021888/article/details/132450964
Recommended