Comments (11)
@joachimmueller that's fine.
I've found another place in the YOURLS code that is making it hard, if not impossible, to use Apache to proxy YOURLS with a sub-path. I've submitted another PR for that situation:
from images.
Thanks for your report @joachimmueller.
That said this is a very weird setup, and I'm pretty sure the issue is nothing with the YOURLS Docker image directly.
Did you try with another Docker image, let's say WordPress one?
If so, you must provide some Docker and/or Apache logs to go further.
from images.
WOW, that was an quick reply 👍
The setup is not that weird. I just have no control of the hosts sub domains and must use a path to access yourls. It's even one possible containerless setup: https://github.com/YOURLS/YOURLS/wiki/.htaccess.
I guess it would require to copy the source into a subdirectory by the docker-entrypoint.sh script.
Does anybody has this requirement as well (running docker-yourls behind a path)?
from images.
It's even one possible containerless setup
Hmm, that's not exactly the same case.
The setup described in the wiki is when you directly access a sub-directory.
Your setup is a sub-path shadowed by a proxy. In that case the complicated part is proxy' configuration written to perform the perfect rewrite (if even possible).
Are you sure it is possible? I.e. have you tested successfully with another docker image?
from images.
Closing for now, as it seems to be unrelated to docker-yourls specifically, but please don't hesitate to post below any new info or test results.
from images.
I've found one error in the underlying yourls code which prevents the Docker container from being proxied 100% successfully and I've raised a PR to fix it:
@joachimmueller did you manage to get this working? I'm still hitting some issues that I'm digging into the yourls code to try and figure out what is going on.
from images.
We switched to a subdomain. Sorry, can't help at the moment.
from images.
I've got to a point where it doesn't seem to be easy to fix this problem.
Option 1: proxy from a path to a root-space container, e.g. ProxyPass /app/ http://localhost:8002/
in Apache and YOURLS_SITE
set to the full parent path, e.g. http://test.example.com/app
With this approach, the UI all works but the shortlinks don't. The reason why the shortlinks don't work is because yourls in the container thinks it is working at the root of the URL so when yourls_get_request
is called, it hits:
$uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
which results in $uri
being set to test.example.com/test-link
and not test.example.com/app/test-link
so the loader fails.
Option 2. proxy from a path to the same path inside the container, e.g. ProxyPass /app/ http://localhost:8002/app/
in Apache and YOURLS_SITE
set to the full parent path, e.g. http://test.example.com/app
With this approach, shortlinks work but the UI doesn't. The problem is that the .htaccess
file triggers yourls-loader.php
. The instructions for .htaccess
(https://github.com/YOURLS/YOURLS/wiki/.htaccess) talk about if YOURLS is installed in a subdirectory, but that doesn't help with this scenario, where YOURLS itself is instead in the root directory but being proxied as if it were in a subdirectory.
So, the solution I've adopted is similar to YOURLS/YOURLS#2604 where I now reference YOURLS_SITE instead of relying on the host information passed via Apache. This turns out to be very similar to the allow-aliases
plugin which means that, if you are using yourls in a Container, that plugin is no longer needed.
Fixed in YOURLS/YOURLS#2608.
from images.
With all of the fixes applied, an Apache configuration file like the following can be used:
<VirtualHost *:80>
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass /yourls/ http://localhost:8002/ connectiontimeout=5 timeout=300
ProxyPassReverse /yourls/ http://localhost:8002/
</VirtualHost>
Note that YOURLS_SITE
in the docker-compose.yml
file must be set to the full hostname and path, e.g. http://test.example.com/yourls
.
from images.
Thanks for this extensive review @pcolmer, very appreciated! 👍
from images.
If someone has trouble configuring this setup with an nginx instead of an Apache reverse proxy (hello to future-me in a few years), the following location snippet for the server configuration did the trick for me. Unfortunately, I already lost the source of the original snippet, where I copied most of it from.
yourls
is the name of my container in the same network as the nginx reverse proxy and go
is the path I am serving it under.
location /go/ {
if ( $uri ~ ^\/go\/((admin|css|images|js)(\/?)(.*)|.*.(\.html|\.php)) ) {
rewrite /go(/.*) $1 break;
}
proxy_pass http://yourls;
proxy_redirect / /go/;
}
In case it matters, I have also defined the following proxy settings:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
client_max_body_size 1024M;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_read_timeout 3600;
from images.
Related Issues (20)
- Dependency Dashboard
- docker container doesn't start after resetting the container HOT 7
- Images on dockerhub and github registry not the same HOT 2
- Setting environment variables to falsy values (0, empty string, etc) reverts to default value HOT 1
- config.php belongs to user root by default: Could not auto-encrypt passwords. Error was: "cannot write file". HOT 2
- Docker data not persisted HOT 6
- "&" in the password bricks the config file (docker) HOT 8
- Old logo on Docker Hub HOT 1
- Error setting `USER` in `Dockerfile` HOT 4
- docker update HOT 1
- Latest Github Expiry plugin not working with latest version of YOURLS HOT 1
- Automatic inclusion of plugin-specific configuration HOT 1
- Volume in docker-compose.yml HOT 2
- Diverts to `install.php` after pulling latest image HOT 5
- Latest `fpm-alpine` image is broken HOT 2
- `fpm` image does not serve static files HOT 1
- White screen with 1.8 using docker HOT 19
- It seems something wrong with your demo yml configs ? HOT 2
- Docker setup doesn't work at all HOT 3
- Mysqli with SSL is broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from images.