nginx获取前端访问地址,发送给后端


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;
 
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;		
		location /api/encrypt/postmb1{
			root html/demo1/;
			proxy_pass http://127.0.0.1:10015/api/encrypt/postmb1;
			proxy_set_header Host $http_host; #后台可以获取到完整的ip+端口号
			proxy_set_header X-Real-IP $remote_addr; #后台可以获取到用户访问的真实ip地址
        }
		location /api/encrypt/postmb2{
			root html/demo1/;
			proxy_pass http://127.0.0.1:10015/api/encrypt/postmb2;
			proxy_set_header Host $http_host; #后台可以获取到完整的ip+端口号
			proxy_set_header X-Real-IP $remote_addr; #后台可以获取到用户访问的真实ip地址
        }
    }
	
	server {
    listen 10017;
    server_name your_domain.com;  # 将your_domain.com替换为你的域名或IP地址

    location /project1 {
        root D:/pr/pr1/dist;  # 将C:/path/to/project1/dist替换为项目1的dist文件夹路径
        index index.html;
        try_files $uri $uri/ /project1/index.html;
    }


    # 添加其他项目的location块...
	}

 


    }
	
	





你可能感兴趣的:(nginx,前端,运维)