OpenFactorioServerManager / factorio-server-manager

A tool to help manage Factorio multiplayer servers including mods and save games.
MIT License
568 stars 135 forks source link

Allow the server to perform behind Nginx reverse proxy #5

Closed ja-ko closed 8 years ago

ja-ko commented 8 years ago

Hi, first things first: Awesome job! Thank you so much!

I'd love to use this tool for my current factorio server. However, the lack of an auth system and ssl support kinda kills the thing for me. My factorio server is hosted in a computing center, so I have to access it via the internet. This makes SSL and authentication a must.

I'm currently trying work around these issues using a nginx reverse proxy. This way ssl is easily added and one could add authentication via nginx as well.

However, via the reverse proxy the frontend is not available. It always gives a 404 or an empty page while everything works just fine without the proxy. The API can be accessed via the reverse proxy.

I'd love to see this problem fixed.

Tell me if I'm wrong (haven't looked into Go and that stuff yet), but wouldn't it make sense if one could serve the static frontend via nginx as well?

However, feel free to message me if you need additional information. I'll continue to look into the issue from my end (trying to somehow force the nginx to get this working :) ), so if you have any additional ideas, please tell me :)

Thanks again!

mroote commented 8 years ago

Hey @drahti,

Reverse proxy should work fine if you configure it to reverse proxy the port the UI is listening on.  Could you post the configuration of your Nginx server?

Since the Go server acts as the fileserver all Nginx has to do is proxy all the requests.  You could use Nginx to serve the static content also just point the routes to where the "app" directory is since that holds all the static content.

On Thu, Apr 28, 2016, at 01:48 PM, Jannik Kolodziej wrote:

Hi, first things first: Awesome job! Thank you so much!

I'd love to use this tool for my current factorio server. However, the lack of an auth system and ssl support kinda kills the thing for me. My factorio server is hosted in a computing center, so I have to access it via the internet. This makes SSL and authentication a must. I'm currently trying work around these issues using a nginx reverse proxy. This way ssl is easily added and one could add authentication via nginx as well. However, via the reverse proxy the frontend is not available. It always gives a 404 or an empty page while everything works just fine without the proxy. The API can be accessed via the reverse proxy. I'd love to see this problem fixed. Tell me if I'm wrong (haven't looked into Go and that stuff yet), but wouldn't it make sense if one could serve the static frontend via nginx as well? However, feel free to message me if you need additional information. I'll continue to look into the issue from my end (trying to somehow force the nginx to get this working :) ), so if you have any additional ideas, please tell me :) Thanks again!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub[1]

Links:

  1. https://github.com/MajorMJR/factorio-server-manager/issues/5
mroote commented 8 years ago

Actually now that I think about it you may need two locations configured in nginx. One to serve the static files from the ./app directory and another to proxy the API requests.

ja-ko commented 8 years ago

serving the ./app directory did the trick for me. Thanks a lot! Would you care about explaining to me why I need to do this? From my understanding the executeable should serve the files even through the reverse proxy, shouldn't it?

Anyway, thanks for everything!

mroote commented 8 years ago

Awesome glad you got it working! If you want to add an example of your configuration to the Readme that would be greatly appreciated.

You need the two location blocks due to the way I setup up the routes between the front and backends. I used React Router for the front end routes like "/mods" or "/saves", but all actual data is transferred from the /api routes. You can check out routes.go if your curious how the router is configured in Go.

ja-ko commented 8 years ago

I'll look into the files. Thanks mate!

Right now I'm setting up a SSL secured docker image with your manager and factorio ready to go. I was going to PullRequest that (and the config with it).