Custom webprefix / webroot. #251

Closed
opened 2022-11-24 20:30:41 +00:00 by gameplayer · 11 comments

Good evening,

Is there a way to set a custom webprefix / webroot?

Good evening, Is there a way to set a custom webprefix / webroot?
Owner

I think what you want is the url setting in the config file?

I think what you want is the `url` setting in the config file?
Author

By default I'm using nginx proxy redirects:

		location /api/ {
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $remote_addr;
                        proxy_pass http://localhost:1156/api/;
                        proxy_redirect http://$host:1156/ /api/;
		}
		
		location ~ ^/.well-known/(webfinger|nodeinfo|host-meta) {
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $remote_addr;
                        proxy_pass http://localhost:1156;
                        proxy_redirect http://$host:1156/ /foundkey/;
						sub_filter ':1156' ':443/foundkey';
                        sub_filter '"/' '"/foundkey/';
                        sub_filter "'/" "'/foundkey/";
                        sub_filter 'url(/' 'url(/foundkey/';
                        sub_filter 'url("/' 'url("/foundkey';
                        sub_filter "url('/" "url('/foundkey";
                        sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/";
                        sub_filter_types *;
                        sub_filter_once off;
                        sub_filter_last_modified on;
                }

		location /streaming {
                        proxy_set_header Host $host;
                        proxy_pass http://localhost:1156/streaming;
                        proxy_redirect http://$host:1156/ /foundkey/;
                        sub_filter ':1156' ':443/foundkey';
                        sub_filter '"/' '"/foundkey/';
                        sub_filter "'/" "'/foundkey/";
                        sub_filter 'url(/' 'url(/foundkey/';
                        sub_filter 'url("/' 'url("/foundkey';
                        sub_filter "url('/" "url('/foundkey";
                        sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/";
                        sub_filter_types *;
                        sub_filter_once off;
                        sub_filter_last_modified on;

                        # For WebSocket
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection $connection_upgrade;
		}

		location /assets/ {
                        proxy_pass http://127.0.0.1:1156/assets/;
                        proxy_set_header Host $host;
                        proxy_http_version 1.1;
                        sub_filter '../' '/foundkey/';
                        proxy_redirect / /foundkey/;
                        sub_filter ':1156' ':443/foundkey';
                        sub_filter '"/' '"/foundkey/';
                        sub_filter "'/" "'/foundkey/";
                        sub_filter 'url(/' 'url(/foundkey/';
                        sub_filter 'url("/' 'url("/foundkey';
                        sub_filter "url('/" "url('/foundkey";
                        sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/";
                        sub_filter_types *;
                        sub_filter_once off;
                        sub_filter_last_modified on;

		}

		location /foundkey/ {
                        proxy_pass http://127.0.0.1:1156/;
                        proxy_set_header Host $host;
                        proxy_http_version 1.1;

                        # For WebSocket
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection $connection_upgrade;

                        sub_filter '../' '/foundkey/';
                        proxy_redirect http://$host:1156/ /foundkey/;
                        sub_filter ':1156' ':443/foundkey';
                        sub_filter '"/' '"/foundkey/';
                        sub_filter "'/" "'/foundkey/";
                        sub_filter 'url(/' 'url(/foundkey/';
                        sub_filter 'url("/' 'url("/foundkey';
                        sub_filter "url('/" "url('/foundkey";
                        sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/";
                        sub_filter_types *;
                        sub_filter_once off;
                        sub_filter_last_modified on;

		}

But it doesn't works well, so the url config would be nice.

By default I'm using nginx proxy redirects: ``` location /api/ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://localhost:1156/api/; proxy_redirect http://$host:1156/ /api/; } location ~ ^/.well-known/(webfinger|nodeinfo|host-meta) { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://localhost:1156; proxy_redirect http://$host:1156/ /foundkey/; sub_filter ':1156' ':443/foundkey'; sub_filter '"/' '"/foundkey/'; sub_filter "'/" "'/foundkey/"; sub_filter 'url(/' 'url(/foundkey/'; sub_filter 'url("/' 'url("/foundkey'; sub_filter "url('/" "url('/foundkey"; sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/"; sub_filter_types *; sub_filter_once off; sub_filter_last_modified on; } location /streaming { proxy_set_header Host $host; proxy_pass http://localhost:1156/streaming; proxy_redirect http://$host:1156/ /foundkey/; sub_filter ':1156' ':443/foundkey'; sub_filter '"/' '"/foundkey/'; sub_filter "'/" "'/foundkey/"; sub_filter 'url(/' 'url(/foundkey/'; sub_filter 'url("/' 'url("/foundkey'; sub_filter "url('/" "url('/foundkey"; sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/"; sub_filter_types *; sub_filter_once off; sub_filter_last_modified on; # For WebSocket proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location /assets/ { proxy_pass http://127.0.0.1:1156/assets/; proxy_set_header Host $host; proxy_http_version 1.1; sub_filter '../' '/foundkey/'; proxy_redirect / /foundkey/; sub_filter ':1156' ':443/foundkey'; sub_filter '"/' '"/foundkey/'; sub_filter "'/" "'/foundkey/"; sub_filter 'url(/' 'url(/foundkey/'; sub_filter 'url("/' 'url("/foundkey'; sub_filter "url('/" "url('/foundkey"; sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/"; sub_filter_types *; sub_filter_once off; sub_filter_last_modified on; } location /foundkey/ { proxy_pass http://127.0.0.1:1156/; proxy_set_header Host $host; proxy_http_version 1.1; # For WebSocket proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; sub_filter '../' '/foundkey/'; proxy_redirect http://$host:1156/ /foundkey/; sub_filter ':1156' ':443/foundkey'; sub_filter '"/' '"/foundkey/'; sub_filter "'/" "'/foundkey/"; sub_filter 'url(/' 'url(/foundkey/'; sub_filter 'url("/' 'url("/foundkey'; sub_filter "url('/" "url('/foundkey"; sub_filter "gameplayer.tru.io/" "gameplayer.tru.io/foundkey/"; sub_filter_types *; sub_filter_once off; sub_filter_last_modified on; } ``` But it doesn't works well, so the url config would be nice.
Owner

I don't understand what you are trying to do and why you are trying to do it.

If you want to use a different base URL for foundkey you can use the url field in the configuration file as I said before.

I don't understand what you are trying to do and why you are trying to do it. If you want to use a different base URL for foundkey you can use the `url` field in the configuration file as I said before.
Author

I mean, I just wanted to have FoundKey under /foundkey/ directory in the URL. But still FoundKey is looking for resources at /.
Why I want to do that is because I want to have main page / on something else.

I mean, I just wanted to have FoundKey under `/foundkey/` directory in the URL. But still FoundKey is looking for resources at `/`. Why I want to do that is because I want to have main page `/` on something else.
Owner

Does this still happen if you set url in .config/default.yml to the base URL? e.g. https://example.com/foundkey/?

Does this still happen if you set `url` in `.config/default.yml` to the base URL? e.g. `https://example.com/foundkey/`?
Author

Yeah, it's ignoring the /foundkey/ element after the domain name.

Yeah, it's ignoring the `/foundkey/` element after the domain name.
Owner

You're not really supposed to do this.
Federation is a very fragile thing and you're essentially moving outboxes and such.
While this could be possible in theory, it would have side effects you are definitely not thinking of in your nginx config.
Requiring people understand AP well to be able to configure stuff in a particular way isn't really reasonable, so it's unlikely support for this will be added.

You're not really supposed to do this. Federation is a very fragile thing and you're essentially moving outboxes and such. While this could be possible in theory, it would have side effects you are definitely not thinking of in your nginx config. Requiring people understand AP well to be able to configure stuff in a particular way isn't really reasonable, so it's unlikely support for this will be added.
toast closed this issue 2022-12-03 10:18:10 +00:00
Author

What side effects will it have?

What side effects will it have?
Owner

If you change the URL after starting the instance, other instances might think that all the old users disappeared for some reason and new actors appeared.

There are also non-enumerated problems that may arise if some path is not redirected correctly, e.g. .well-known. If you really want to do that we would advise you to start your own server implementation instead or use one that supports this.

In our opinion, this feature would require too much consideration and would be too fragile to implement.

If you change the URL after starting the instance, other instances might think that all the old users disappeared for some reason and new actors appeared. There are also non-enumerated problems that may arise if some path is not redirected correctly, e.g. `.well-known`. If you really want to do that we would advise you to start your own server implementation instead or use one that supports this. In our opinion, this feature would require too much consideration and would be too fragile to implement.
Author

There's a second way to change webroot. Host FoundKey through nginx on different port, set X-Frame-Options to ALLOW-FROM SAMEDOMAIN & Embed it into HTML, set as index.html. Finally throw in i.e. /foundkey/ or /social/.

There's a second way to change webroot. Host FoundKey through nginx on different port, set `X-Frame-Options` to `ALLOW-FROM SAMEDOMAIN` & Embed it into HTML, set as `index.html`. Finally throw in i.e. `/foundkey/` or `/social/`.
Author

Also here's the sneak-peak HTML code for redirecting (if location is /foundkey/):

<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv='X-Frame-Options' content='ALLOWAll'/>
    <title>FoundKey</title>
    <link rel="stylesheet" href="/style.css"/>
    <link rel="icon" href="/foundkey.png"/> 
</head>

<body>
	<embed id="core" src="" description="FoundKey" width="100%" height="100%"></embed>
	<script>
		document.getElementById("core").src = window.location.href.replace(window.location.hostname, "gameplayer.tru.io:15350").replace(":15350/foundkey/", ":15350/");
	</script>
</body>

In nginx set:

error_page 404 =200 /foundkey/index.html;
Also here's the sneak-peak HTML code for redirecting (if location is /foundkey/): ```html <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"/> <meta http-equiv='X-Frame-Options' content='ALLOWAll'/> <title>FoundKey</title> <link rel="stylesheet" href="/style.css"/> <link rel="icon" href="/foundkey.png"/> </head> <body> <embed id="core" src="" description="FoundKey" width="100%" height="100%"></embed> <script> document.getElementById("core").src = window.location.href.replace(window.location.hostname, "gameplayer.tru.io:15350").replace(":15350/foundkey/", ":15350/"); </script> </body> ``` In nginx set: ``` error_page 404 =200 /foundkey/index.html; ```
Sign in to join this conversation.
No labels
feature
fix
upkeep
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: FoundKeyGang/FoundKey#251
No description provided.