traefik / ProxyPass: using stripprefix, I get a 404 for sub queries - docker

I try to configure my registry service to intercep host+path https://my-dns.org/registry and redirect to the service http://registry-ui
here is configured my compose :
...
registry-ui:
image: joxit/docker-registry-ui:latest
container_name: registry-ui
restart: unless-stopped
environment:
- REGISTRY_TITLE=My registry
- NGINX_PROXY_PASS_URL=http://registry:5000
- SINGLE_REGISTRY=true
- DELETE_IMAGES=true
depends_on:
- registry
labels:
- "traefik.enable=true"
- "traefik.http.routers.registry-ui.entrypoints=https"
- "traefik.http.routers.registry-ui.rule=Host(`my-dns.org`) && PathPrefix(`/registry`)"
- "traefik.http.routers.registry-ui.middlewares=test-stripprefix"
- "traefik.http.routers.registry-ui.tls.certresolver=myresolver"
- "traefik.http.middlewares.test-stripprefix.stripprefix.prefixes=/registry"
- "traefik.http.middlewares.test-stripprefix.stripprefix.forceSlash=false"
- "traefik.http.services.registry-ui.loadbalancer.server.port=80"
...
As a result, the index page works fine, but css, js and favicon are lost because the requests look like :
https://my-dns.org/docker-registry-ui.css instead of
https://my-dns.org/registry/docker-registry-ui.css
Any idea on how to fix that ?

This will only work as long as the app you are trying to start does NOT set a custom html <base> to something hardcoded like root /.
If this is not the case you might be in luck!
Your links to sub resources are probably defined relative something like this.
<link rel="stylesheet" type="text/css" href="docker-registry-ui.css" />
So when you enter into the browser https://my-dns.org/registry your page opens but all links and subsequently css, js is completely broken because the base directory the relative links are based on is still the directory https://my-dns.org/ because you did not enter a subdirectory. The /registry is handled like it is a file and is ignored for relative links.
URL: https://my-dns.org/registry
Base: https://my-dns.org/
Relative Link: docker-registry-ui.css
Result: https://my-dns.org/docker-registry-ui.css ⇒ HTTP 404 not found
For your path prefix to work you need to enter a trailing slash / to access your service. Then the relative links will work as expected.
URL: https://my-dns.org/registry/
Base: https://my-dns.org/registry/
Relative Link: docker-registry-ui.css
Result: https://my-dns.org/registry/docker-registry-ui.css ⇒ Link working as expected
Try to access your service with https://my-dns.org/registry/ (trailing slash) for your links to work as expected.
If you really must use the link without the trailing slash / to work, you need a path rewrite step to add the trailing slash or alternatively a redirection from https://my-dns.org/registry to https://my-dns.org/registry/.
Adjust your configuration to add add the trailing slash:
labels:
- "traefik.enable=true"
- "traefik.http.routers.registry-ui.entrypoints=https"
- "traefik.http.routers.registry-ui.rule=Host(`my-dns.org`) && PathPrefix(`/registry/`)"
- "traefik.http.routers.registry-ui.middlewares=test-stripprefix"
- "traefik.http.routers.registry-ui.tls.certresolver=myresolver"
- "traefik.http.middlewares.test-stripprefix.stripprefix.prefixes=/registry/"
- "traefik.http.services.registry-ui.loadbalancer.server.port=80"

Related

how to set up app.yaml to redirect all urls with a . in them to files in a rails app's public folder?

I have a rails app on GCP using the App Engine Ruby Standard Environment (though this question could apply to any GCP app). At first I was trying to set things up so that /* gets handled by static files in the public directory of my Rails app, and otherwise falls back to the Rails app for unmatched URLs. This does not seem to be possible, however it occurred to me that I could set all urls containing a . to be handled by static files within public (in my particular app this would work fine).
I am confused on the documentation for static_files and upload (particularly the part about /\1 in the example at https://cloud.google.com/appengine/docs/standard/ruby/config/appref#handlers_element, but here is the handlers section of my app.yaml file that I came up with. It does not work and simply 404s on all paths I throw at it:
handlers:
- url: /*\.*
static_files: public/\1
upload: public/*
- url: /.*
secure: always
script: auto
This doesn't work as all paths go to the rails app which then 404s on all static file paths.
This one has the opposite problem -- static files work but no paths go to the rails app:
handlers:
- url: /*\.*
static_dir: public
- url: /.*
secure: always
script: auto
This one worked -- a slight tweak from one of the options from #gaefan
handlers:
- url: /(.*\..*)
static_files: public/\1
upload: public/.*\..*
- url: /.*
secure: always
script: auto
For your first example, I believe parentheses are required and you need to fix your regex. It should be something like:
handlers:
- url: /(.*\..*)
static_files: public/\1
upload: public/*
- url: /.*
secure: always
script: auto
For the second one, you have a mistake in your regex. It should be:
handlers:
- url: /.*\..*
static_dir: public
- url: /.*
secure: always
script: auto

tx_news n:link don't want build absolute link with config.absPrefix

in tx_news template we have <n:link which follow <f:link.typolink seems we can use configuration="{forceAbsoluteUrl: 1}" and get
<h3>
<n:link configuration="{forceAbsoluteUrl: 1}" newsItem="{newsItem}" settings="{settings}" title="{newsItem.title}">
<span itemprop="headline">{newsItem.title}</span>
</n:link>
</h3>
For build absolute link TYPO3 use config.absPrefix but no effect in TYPO3 9.5.3. I can change this settings just in Site Configuration -> Entry Point. But not more in typoscript.
I've checked. This typoscript setting still available in TYPO3 9.5.3. But looks like work just for assets (scripts/styles in header) no more for links? Can i fix that?
In end i need absolute links in tx_news from config.absPrefix or other typoscript but not config.yaml
Try with config.absRefPrefix instead of config.absPrefix
No one solution from typoscript dont work in TYPO3 v9.5.x so I have to use Site manager Variants
rootPageId: 1
base: www.livedomain.com
baseVariants:
-
base: 'http://localhost'
condition: 'applicationContext == "Development"'
-
base: 'https://stagedomain.com'
condition: 'applicationContext == "Testing"'
And in my apache2 or .htaccess
SetEnv TYPO3_CONTEXT Development
or
SetEnv TYPO3_CONTEXT Testing
If context not set website use base url in other cases from baseVariants

Make about: page think it is https (or chrome:// page safe for untrusted)

I was wondering if it is possible to make Firefox think a page is https?
I have set up an about: page and used these flags to make it think it is http:
getURIFlags: function(aURI) {
return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | Ci.nsIAboutModule.ALLOW_SCRIPT | Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD;
},
The URI_SAFE_FOR_UNTRUSTED_CONTENT makes it be just like a regular webpage.
Is there anway to make it act like https? Because otherwise I can't get webrtc screensharing to work on it.
I also tried tricky things like setCurrentURI from framesccript to change the location to something else:
var webNav = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
webNav.setCurrentURI(Services.io.newURI('https://mozilla.github.io/', null, null));
This also didn't work.
Or is there anyway to make chrome:// pages be URI_SAFE_FOR_UNTRUSTED_CONTENT? I tried setting contentaccessible=yes in the manifest and that didn't do it:
content screencastify ./ contentaccessible=yes
locale screencastify en-US locale/en-US/

Current site URL in Liferay 6.2

I cannot figure out how to get URL of current site in Liferay. For example if i have created four sites - site1, site2, site3, site4. URL of this sites will be:
http://localhost:8080/web/site1/
http://localhost:8080/web/site2/
http://localhost:8080/web/site3/
http://localhost:8080/web/site4/
But how can i get this URLs from velocity (in theme)? I tried few options:
$themeDisplay.getPathFriendlyURLPublic() - /web
$themeDisplay.getPortalURL() - http://localhost:8080
$themeDisplay.getURLHome() - http://localhost:8080/web/guest
$themeDisplay.getURLCurrent() - /web/site1/home
I need to get just http://localhost:8080/web/actualsite/.
All right, after few hours of trying I find solution:
To get current site url, you need to use:
$layout.getGroup().friendlyURL in velocity.
This expression returns '/site-name' format.
Try this in your theme vm. This should give you current complete url.
$portalUtil.getCurrentCompleteURL($request)
Output : http://localhost:8080/web/site4/home

How to point requireJS text plugin to an MVC action

I want to load HTML from an ASP.NET MVC 4 action. So full URL looks like:
http://localhost:7588/en/Dialogs/AclManager
Here is how I declare dependency:
define(['jquery', 'text!AclManager'], function...
Here is my require.config excerpt:
require.config({ paths: { 'AclManager' : '/en/Dialog/AclManager' }});
With this configuration text plugin doesn't find extension and tries to load: /scripts/.AclManager
if I declare dependency as AclManager. (notice dot), then require goes to `/en/Dialogs/AclManager.' which is almost right, except that dot at the end.
I could declare dependency as AclManager/. and this works because my server will ignore trailing /, but I would rather not have a trailing slash there.
What would be an easy way to point text to the URL I need?

Resources