用 Nginx 反向代理 Office Web App 遇到了問題
問題描述
微軟的 Office Web App 可以直接在線預覽 office 文檔。效果如 http://www.labnol.org/internet/google-docs-viewer-alternative/26591/
我需要在自己的網站中以 iframe 的形式嵌入頁面中,并可以操作 iframe 中的元素,于是想到可以用反代 Office Web App 來解決跨域問題。
在用 Nginx 反代過程中遇到了一些問題。
Nginx 配置如下
location /document { proxy_pass https://view.officeapps.live.com; proxy_set_header host $http_host; proxy_set_header X-real-IP $remote_addr; proxy_set_header X-forwarded-for $proxy_add_x_forwded_for; }
問題如下:
訪問 my.domain.com/document,頁面錯誤內容為:404-File or directory not found.(IIS)
訪問 my.domain.com/document/op/view.aspx?src=http://img.labnol.org/di/Word.docx頁面錯誤內容為:404 NOT Found(Nginx/1.6.2),并且請求被重定向到my.domain.com/error/error.html?aspxerrorpath=/document/op/view/aspx
Nginx 用的不多,試了好久都沒有找到原因,請大家指點一下。
問題解答
回答1:在別人的幫助下找到原因了 第二行改為 roxy_pass https://view.officeapps.live.com/; 就可以了
相關文章:
1. MySQL數據庫中文亂碼的原因2. 如何解決Centos下Docker服務啟動無響應,且輸入docker命令無響應?3. mysql - 新浪微博中的關注功能是如何設計表結構的?4. angular.js使用$resource服務把數據存入mongodb的問題。5. dockerfile - [docker build image失敗- npm install]6. angular.js - 關于$apply()7. android-studio - Android Studio 運行項目的時候一堆警告,跑步起來!?8. 我在centos容器里安裝docker,也就是在容器里安裝容器,報錯了?9. angular.js - Ionic 集成crosswalk后生成的apk在android4.4.2上安裝失敗???10. nignx - docker內nginx 80端口被占用
