TechnicPack / TechnicSolder

PHP web app that brings differential updates to the Technic Launcher and Technic Platform
https://docs.solder.io/
Other
169 stars 167 forks source link

Incompatible with subdirectories #659

Closed forresthopkinsa closed 6 years ago

forresthopkinsa commented 6 years ago

Solder fails to run when not running as the web root.

Expected behavior is that it runs just fine in subdirectories.

The actual problem arises when trying to install the pack:

image

It responds with Error unzipping a file for the following pack...

forresthopkinsa commented 6 years ago

This is the error I'm getting in my launcher logs. You can see that it's initially trying to hit the right URL -- /solder/api/modpack/ -- but then it instead resorts to sending requests to /api/modpack, which of course fails.

[B#360] 2018/06/09 21:26:26 [SEVERE] net.technicpack.rest.RestfulAPIException: Error accessing URL [http://forresthopkinsa.com/solder/api/modpack/]
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.rest.RestObject.getRestObject(RestObject.java:157)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.solder.http.HttpSolderApi.getMirrorUrl(HttpSolderApi.java:59)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.solder.cache.CachedSolderApi.getMirrorUrl(CachedSolderApi.java:134)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.platform.PlatformPackInfoRepository.getInfoFromPlatformInfo(PlatformPackInfoRepository.java:72)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.platform.PlatformPackInfoRepository.getPlatformPackInfo(PlatformPackInfoRepository.java:60)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.platform.PlatformPackInfoRepository.getCompletePackInfo(PlatformPackInfoRepository.java:51)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.launchercore.modpacks.PackLoadJob$6.run(PackLoadJob.java:190)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at java.lang.Thread.run(Thread.java:748)
[B#360] 2018/06/09 21:26:26 [SEVERE] Caused by: java.io.FileNotFoundException: http://forresthopkinsa.com/api/modpack
[B#360] 2018/06/09 21:26:26 [SEVERE]     at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1890)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
[B#360] 2018/06/09 21:26:26 [SEVERE]     at net.technicpack.rest.RestObject.getRestObject(RestObject.java:137)
[B#360] 2018/06/09 21:26:26 [SEVERE]     ... 7 more

This might make it seem like a launcher problem (and it partially is a launcher problem; I'll make a separate issue for that), but I don't think that's the whole story.

The reason it resorts to the root URL is because, when you try to hit /solder/api/modpack, the .htaccess file catches the trailing slash and responds with a 301, permanently redirecting to /api/modpack.

This is the result of a long-since-fixed bug in Laravel which would redirect trailing-slash URLs without taking directory context into account.

Indemnity83 commented 6 years ago

Installing TechnicSolder in a subdirectory is not a supported configuration; primarily because as you've pointed out it is not a supported configuration in Laravel 4.2 (the fix you've linked to is version 5.5) but also because it can significantly complicate troubleshooting.

Solder can easily be run under a subdomain, and is generally the recommended approach to be used.

forresthopkinsa commented 6 years ago

The only reason it fails is because of that htaccess file. Just because Laravel didn't used to provide support for non-default configurations doesn't mean it's a breaking change.

Subdomains are fine and dandy until you start running a slightly less simple setup, in which case it doesn't make sense to use subdomains over subdirectories.

forresthopkinsa commented 6 years ago

Additionally -- if your goal is to make troubleshooting easier, I've gotta say, this is really counterproductive. Do you know how long it took just for me to figure out that the subdirectory was the problem?

Nowhere in the code does it ever catch a subdirectory configuration as incorrect. Look at the first post in this issue -- do you expect users to see that error page and assume that the problem is subdirectories?

The documentation, as far as I know, doesn't mention subdirectories anywhere. Here's a fantastic compromise that I think can serve everyone well: We add a prominent section to the docs that explains to users that it's highly recommended to not run in a subdirectory unless they really know what they're doing.

And then, if anyone ever asks for help with their subdir setup, you can tell them that you don't support that configuration.

If, on the other hand, the users know what they're doing (which isn't a crazy assumption for a back-end server software) then I don't see the harm in allowing them to use more advanced configurations. Especially as the fix is such a simple one; it doesn't even touch the code in this project.

Jerlag01 commented 6 years ago

normal users follow the guide in the first place and don't screw around with "advanced" configurations. Normal users also just install web applications to the right directory that is created by the webservice itself and not a seperate one that is somewhere located on the system

forresthopkinsa commented 6 years ago

@Jerlag01 You're right. This doesn't concern casual users who install Solder on Windows systems. This is for more heavy-duty use in dedicated headless systems.

Also -- I'm not sure what you mean by "the right directory that is created by the webservice itself and not a separate one". Can you elaborate on what you're trying to say with that? Are you suggesting that users should be placing the solder installation directly into an Apache-generated directory?

If so, I'm afraid that's not the case. Conventional wisdom suggests that with any kind of web installation, you should definitely be keeping the installation somewhere else on the system, and symlinking the necessary files to a virtual directory that Apache can access.

Jerlag01 commented 6 years ago

i run solder also on a linux system, the windows part is just because i wondered if it would also work on there. but windows is out of the question here.

"The right directory of the webservice": nginx has usr/share/nginx/html apache has var/www/html you told me that you made a symlink to the solder directory which means that you are not running solder in the default webservice directory. if you would then you wouldn't need to do that stuff like creating a symlink. Also you can keep different web appllcation from each other by just putting it a subdirectory in the default paths and configure your webserver correctly as it suggest in the guides.

forresthopkinsa commented 6 years ago

The configuration you're suggesting -- keeping all the files directly in the server installation -- is not correct. But that has nothing to do with this. None of this has to do with the issue above. If you want to argue about standard ways to run web servers, we can do it in Discord. I'm trying to submit a PR here, and all of this is just noise.

Jerlag01 commented 6 years ago

well it's been denied as indemnity himself said:

Installing TechnicSolder in a subdirectory is not a supported configuration; primarily because as you've pointed out it is not a supported configuration in Laravel 4.2 (the fix you've linked to is version 5.5) but also because it can significantly complicate troubleshooting.

Solder can easily be run under a subdomain, and is generally the recommended approach to be used.

just deal with it, it won't change

forresthopkinsa commented 6 years ago

@Jerlag01 Like I said, take the arguing somewhere else. A Github issue is no place for this. Leave it alone.

forresthopkinsa commented 5 years ago

Thanks @Pyker !