mirror of
https://github.com/minio/minio.git
synced 2025-10-30 00:05:02 -04:00
browser: Remove hardcoding of minioBrowserPrefix=/minio (#5048)
This enable reverse proxy of minio-browser. Fixes #5040
This commit is contained in:
parent
7d18f00116
commit
7e7ae29d89
@ -5,13 +5,13 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Minio Browser</title>
|
<title>Minio Browser</title>
|
||||||
<link rel="stylesheet" href="/minio/loader.css" type="text/css">
|
<link rel="stylesheet" href="loader.css" type="text/css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="page-load">
|
<div class="page-load">
|
||||||
<div class="pl-inner">
|
<div class="pl-inner">
|
||||||
<img src="/minio/logo.svg" alt="">
|
<img src="logo.svg" alt="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
@ -27,19 +27,19 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="http://www.google.com/chrome/">
|
<a href="http://www.google.com/chrome/">
|
||||||
<img src="/minio/chrome.png" alt="">
|
<img src="chrome.png" alt="">
|
||||||
<div>Chrome</div>
|
<div>Chrome</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://www.mozilla.org/en-US/firefox/new/">
|
<a href="https://www.mozilla.org/en-US/firefox/new/">
|
||||||
<img src="/minio/firefox.png" alt="">
|
<img src="firefox.png" alt="">
|
||||||
<div>Firefox</div>
|
<div>Firefox</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://www.apple.com/safari/">
|
<a href="https://www.apple.com/safari/">
|
||||||
<img src="/minio/safari.png" alt="">
|
<img src="safari.png" alt="">
|
||||||
<div>Safari</div>
|
<div>Safari</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -51,6 +51,6 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<script>currentUiVersion = 'MINIO_UI_VERSION'</script>
|
<script>currentUiVersion = 'MINIO_UI_VERSION'</script>
|
||||||
<script src="/minio/index_bundle.js"></script>
|
<script src="index_bundle.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -81,7 +81,7 @@ ReactDOM.render((
|
|||||||
<Provider store={ store } web={ web }>
|
<Provider store={ store } web={ web }>
|
||||||
<Router history={ browserHistory }>
|
<Router history={ browserHistory }>
|
||||||
<Route path='/' component={ App }>
|
<Route path='/' component={ App }>
|
||||||
<Route path='minio' component={ App }>
|
<Route path={ minioBrowserPrefix } component={ App }>
|
||||||
<IndexRoute component={ Browse } onEnter={ authNeeded } />
|
<IndexRoute component={ Browse } onEnter={ authNeeded } />
|
||||||
<Route path='login' component={ Login } onEnter={ authNotNeeded } />
|
<Route path='login' component={ Login } onEnter={ authNotNeeded } />
|
||||||
<Route path=':bucket' component={ Browse } onEnter={ authNeeded } />
|
<Route path=':bucket' component={ Browse } onEnter={ authNeeded } />
|
||||||
|
|||||||
@ -465,7 +465,7 @@ export const uploadFile = (file, xhr) => {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const {currentBucket, currentPath} = getState()
|
const {currentBucket, currentPath} = getState()
|
||||||
const objectName = `${currentPath}${file.name}`
|
const objectName = `${currentPath}${file.name}`
|
||||||
const uploadUrl = `${window.location.origin}/minio/upload/${currentBucket}/${objectName}`
|
const uploadUrl = `${window.location.origin}${minioBrowserPrefix}/upload/${currentBucket}/${objectName}`
|
||||||
// The slug is a unique identifer for the file upload.
|
// The slug is a unique identifer for the file upload.
|
||||||
const slug = `${currentBucket}-${currentPath}-${file.name}`
|
const slug = `${currentBucket}-${currentPath}-${file.name}`
|
||||||
|
|
||||||
|
|||||||
@ -157,7 +157,7 @@ export default class Browse extends React.Component {
|
|||||||
// Download the selected file.
|
// Download the selected file.
|
||||||
web.CreateURLToken()
|
web.CreateURLToken()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let url = `${window.location.origin}/minio/download/${currentBucket}/${encPrefix}?token=${res.token}`
|
let url = `${window.location.origin}${minioBrowserPrefix}/download/${currentBucket}/${encPrefix}?token=${res.token}`
|
||||||
window.location = url
|
window.location = url
|
||||||
})
|
})
|
||||||
.catch(err => dispatch(actions.showAlert({
|
.catch(err => dispatch(actions.showAlert({
|
||||||
@ -433,8 +433,7 @@ export default class Browse extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
web.CreateURLToken()
|
web.CreateURLToken()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let requestUrl = location.origin + "/minio/zip?token=" + res.token
|
let requestUrl = location.origin + minioBrowserPrefix + "/zip?token=" + res.token
|
||||||
|
|
||||||
this.xhr = new XMLHttpRequest()
|
this.xhr = new XMLHttpRequest()
|
||||||
dispatch(actions.downloadSelected(requestUrl, req, this.xhr))
|
dispatch(actions.downloadSelected(requestUrl, req, this.xhr))
|
||||||
})
|
})
|
||||||
@ -503,7 +502,7 @@ export default class Browse extends React.Component {
|
|||||||
settingsFunc={ this.showSettings.bind(this) }
|
settingsFunc={ this.showSettings.bind(this) }
|
||||||
logoutFunc={ this.logout.bind(this) } />
|
logoutFunc={ this.logout.bind(this) } />
|
||||||
} else {
|
} else {
|
||||||
loginButton = <a className='btn btn-danger' href='/minio/login'>Login</a>
|
loginButton = <a className='btn btn-danger' href={minioBrowserPrefix+'/login'}>Login</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (web.LoggedIn()) {
|
if (web.LoggedIn()) {
|
||||||
|
|||||||
@ -17,7 +17,9 @@
|
|||||||
// File for all the browser constants.
|
// File for all the browser constants.
|
||||||
|
|
||||||
// minioBrowserPrefix absolute path.
|
// minioBrowserPrefix absolute path.
|
||||||
export const minioBrowserPrefix = '/minio'
|
var p = window.location.pathname
|
||||||
|
export const minioBrowserPrefix = p.slice(0, p.indexOf("/", 1))
|
||||||
|
|
||||||
export const READ_ONLY = 'readonly'
|
export const READ_ONLY = 'readonly'
|
||||||
export const WRITE_ONLY = 'writeonly'
|
export const WRITE_ONLY = 'writeonly'
|
||||||
export const READ_WRITE = 'readwrite'
|
export const READ_WRITE = 'readwrite'
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/elazarl/go-bindata-assetfs"
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
@ -55,7 +56,7 @@ func assetFS() *assetfs.AssetFS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// specialAssets are files which are unique files not embedded inside index_bundle.js.
|
// specialAssets are files which are unique files not embedded inside index_bundle.js.
|
||||||
const specialAssets = "loader.css|logo.svg|firefox.png|safari.png|chrome.png|favicon.ico"
|
const specialAssets = ".*index_bundle.*.js$|.*loader.css$|.*logo.svg$|.*firefox.png$|.*safari.png$|.*chrome.png$|.*favicon.ico$"
|
||||||
|
|
||||||
// registerWebRouter - registers web router for serving minio browser.
|
// registerWebRouter - registers web router for serving minio browser.
|
||||||
func registerWebRouter(mux *router.Router) error {
|
func registerWebRouter(mux *router.Router) error {
|
||||||
@ -90,13 +91,20 @@ func registerWebRouter(mux *router.Router) error {
|
|||||||
webBrowserRouter.Methods("POST").Path("/zip").Queries("token", "{token:.*}").HandlerFunc(web.DownloadZip)
|
webBrowserRouter.Methods("POST").Path("/zip").Queries("token", "{token:.*}").HandlerFunc(web.DownloadZip)
|
||||||
|
|
||||||
// Add compression for assets.
|
// Add compression for assets.
|
||||||
compressedAssets := handlers.CompressHandler(http.StripPrefix(minioReservedBucketPath, http.FileServer(assetFS())))
|
h := http.FileServer(assetFS())
|
||||||
|
compressedAssets := handlers.CompressHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
idx := strings.LastIndex(r.URL.Path, slashSeparator)
|
||||||
|
if idx != -1 {
|
||||||
|
r.URL.Path = r.URL.Path[idx+1:]
|
||||||
|
}
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
}))
|
||||||
|
|
||||||
// Serve javascript files and favicon from assets.
|
// Serve javascript files and favicon from assets.
|
||||||
webBrowserRouter.Path(fmt.Sprintf("/{assets:[^/]+.js|%s}", specialAssets)).Handler(compressedAssets)
|
webBrowserRouter.Path(fmt.Sprintf("/{assets:%s}", specialAssets)).Handler(compressedAssets)
|
||||||
|
|
||||||
// Serve index.html for rest of the requests.
|
// Serve index.html for rest of the requests.
|
||||||
webBrowserRouter.Path("/{index:.*}").Handler(indexHandler{http.StripPrefix(minioReservedBucketPath, http.FileServer(assetFS()))})
|
webBrowserRouter.Path("/{index:.*}").Handler(indexHandler{http.StripPrefix(minioReservedBucketPath, h)})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user