Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option --baseurl to allow running behind a reverse proxy #50

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

vi
Copy link
Contributor

@vi vi commented Nov 8, 2020

Overriding base URL from / to other value modifies all links in directory listings to begin from custom location instead of just /.

This allows using simple-http-server behind a reverse proxy that maps only request from a website's "subdirectory" to simple-http-server.

Example nginx config snippet:

location /filemanager/ {
    rewrite /filemanager/(.*) /$1 break;
    proxy_pass http://127.0.0.1:7682/;
    proxy_request_buffering off;
    proxy_buffering off;
}

This pull request also includes #49.

@micwoj92
Copy link

micwoj92 commented Jul 9, 2022

This branch has conflicts that must be resolved

@vi vi force-pushed the baseurl branch 3 times, most recently from 25d2561 to ffbae85 Compare October 28, 2022 01:04
@vi
Copy link
Contributor Author

vi commented Oct 28, 2022

@micwoj92 Rebased, also fixed redirect when uploading files.

@micwoj92
Copy link

Thank you @vi , a screen-oriented text editor software application.

@stappersg
Copy link

git remote add vi https://github.com/vi/simple-http-server
git fetch vi
git cherry-pick ffbae85d8337997cc741

I have now this merge request in my fork

@vi
Copy link
Contributor Author

vi commented Mar 16, 2024

Is three a specific reason why this can't be upstreamed?

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated
@@ -209,6 +209,12 @@ fn main() {
.long("open")
.short("o")
.help("Open the page in the default browser"))
.arg(clap::Arg::with_name("baseurl")
.short("b")
.long("baseurl")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.long("baseurl")
.long("base-url")

src/main.rs Outdated
@@ -429,6 +438,7 @@ struct MainHandler {
compress: Option<Vec<String>>,
try_file_404: Option<PathBuf>,
upload_size_limit: u64,
baseurl: String,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
baseurl: String,
base_url: String,

@TheWaWaR
Copy link
Owner

Is three a specific reason why this can't be upstreamed?

Sorry for so late reply, just don't have much time to test.

Please also rebase the code.

src/main.rs Outdated Show resolved Hide resolved
@vi
Copy link
Contributor Author

vi commented Mar 17, 2024

Done.

@TheWaWaR
Copy link
Owner

Thanks!

@TheWaWaR TheWaWaR merged commit 0d4e3f9 into TheWaWaR:master Mar 18, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants