場景
需求是從A系統中預覽B系統中抓拍的照片。
B系統在另一條服務器上,照片的路徑是絕對路徑
類似D:\aa\badao.jpg這樣的圖片路徑。
在A系統中查詢B系統的數據庫能獲取圖片的路徑。
需要將此圖片路徑映射為網絡URL,使在A系統中能通過網絡URL實現預覽。
Nginx在Windows下載安裝啟動與配置前后端請求代理:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/108122023
在上面進行Nginx的安裝和配置后。
配置靜態資源映射是一樣的流程。
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
關注公眾號
霸道的程序猿
獲取編程相關電子書、教程推送與免費下載。
實現
照片在B系統服務器上的路徑為D盤下pic_old
然后照片路徑都是在數據庫中進行存儲的
存儲的是完整的磁盤路徑。
首先下載Nginx,然后復制到B系統所在的服務器上,打開conf下的nginx.conf
添加一個靜態資源服務器
server { listen 250; server_name 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; location / { root D:/pic_old/; try_files $uri $uri/ /index.html; index index.html index.htm; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
這里代表監聽250端口,並且將請求過來的根路徑映射為下面的
root路徑
D:/pic_old/
配置完成后,保存,然后到bin下打開cmd
start nginx.exe
啟動nginx
然后就可以打開瀏覽器訪問
這個路徑就等同於D:/pic_old/
所以后面加上照片文件的具體路徑,就可以實現在靜態資源服務器映射訪問。
然后如果要是在A系統的服務器或者其他瀏覽器中預覽,必須開放B系統所在服務器的250端口。