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

Feature Request: Enable relative path like http://www.example.com/hackmd #86

Closed
adachij2002 opened this issue Feb 12, 2016 · 11 comments
Closed

Comments

@adachij2002
Copy link

I'd like to configure apache to serve hackmd at any route like http://example.com/hackmd.

@jackycute
Copy link
Member

I haven't tried this yet, I use nginx more.
But I think you can achieve that by reverse proxy?

https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

@adachij2002
Copy link
Author

Yes, I'm using mod_proxy_http as follows, that works fine.

<Location />
    ProxyPass http://localhost:3000/
    ProxyPassReverse http://localhost:3000/
</Location>

But It's not working as follows, because static file or redirect path uses fixed path like "/", "/new", "/css" and so on.

<Location /hackmd>
    ProxyPass http://localhost:3000/hackmd
    ProxyPassReverse http://localhost:3000/hackmd
</Location>

@jackycute
Copy link
Member

OK, I will see what I can do.

@jackycute
Copy link
Member

Supported in b2b1be3
You will need following configs for apache (I tried):

For example, your url is www.example.com/hackmd, hackmd run on port 3000

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /hackmd/{.*} ws://localhost:3000/$1 [P,L]

RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteRule /hackmd/(.*) ws://localhost:3000/$1 [P,L]

ProxyRequests Off
ProxyPreserveHost On

ProxyPass        /hackmd http://localhost:3000
ProxyPassReverse /hackmd http://localhost:3000

ProxyPass        /hackmd/socket.io http://localhost:3000/socket.io
ProxyPassReverse /hackmd/socket.io http://localhost:3000/socket.io

ProxyPass        /hackmd/socket.io ws://localhost:3000/socket.io
ProxyPassReverse /hackmd/socket.io ws://localhost:3000/socket.io

@jackycute
Copy link
Member

Hi @adachij2002
Did you see this issue update?
Please tell me when you're good.

@adachij2002
Copy link
Author

It works fine for me.Thank you!
But this apache configuration is a little bit complex.
Is it difficult to wait on the following URL by Node.js?

http://localhost:3000/hackmd
http://localhost:3000/hackmd/socket.io
ws://localhost:3000/hackmd/socket.io

@jackycute
Copy link
Member

It's not possible without proxy http://localhost:3000/hackmd
But seems ok to be like this:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /hackmd/{.*} ws://localhost:3000/$1 [P,L]

RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteRule /hackmd/(.*) ws://localhost:3000/$1 [P,L]

ProxyRequests Off
ProxyPreserveHost On

ProxyPass        /hackmd http://localhost:3000
ProxyPassReverse /hackmd http://localhost:3000

@adachij2002
Copy link
Author

It's not possible without proxy http://localhost:3000/hackmd

I see.

Do you Sing in via OAuth with that configuration?
I caught error as follows.

Not Found
The requested URL /auth/github/callback was not found on this server.

I configured apache like this

ProxyPass        /auth http://localhost:3000/auth
ProxyPassReverse /auth http://localhost:3000/auth

But I caught error as follows.

AuthorizationError: The redirect_uri MUST match the registered callback URL for this application.

@jackycute
Copy link
Member

Actually, you don't need to config apache like that (proxy /auth)

That error is caused by the OAuth provider setting's callback url not match the one you send.
So you need to modify the callback url whenever you change your server url.

For example, GitHub would like this:
2016-02-20 9 36 48

@adachij2002
Copy link
Author

Sorry for my miss configuration.
It works fine!
Please close this ticket.
Thanks a lot.

@jackycute
Copy link
Member

👍 Happy Coding!

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

No branches or pull requests

2 participants