Rails app served under url segment behind ingress - ruby-on-rails

I am looking for ideas on how to solve the following problem. I want to serve a rails app under an URL segment. The path to the rails app will be https://example.com/app. The landing page https://example.com/ will be bunch of static HTML, CSS, and javascript.
This will be handled by ingress in a kubernetes cluster. Ingress is easy, I have all that configuration ready but the problem as I see it is how to handle redirects between Location /app and Location /.
Is there anything in rails that prevents this? Is it just a matter of trial and error?

Related

How to forward non-www URLs to www URLs

I've had an issue with Google Adsense not being able to access their config file (ads.txt) on my Rails site. I have put it in what I think is the correct folder (App -> Public).
In summary, this is the situation for which URLs work vs not:
[webURL].co.uk/ads.txt (works)
https://www.[webURL].co.uk/ads.txt (works)
http://www.[webURL].co.uk/ads.txt (works)
https://[webURL].co.uk/ads.txt (doesn't work - hangs)
http://[webURL].co.uk/ads.txt (doesn't work - error - HTTP Status: 404 (not found)
So my guess is that Google is trying to reach ads.txt via a URL without a www (the two bottom of the list above).
A couple of other points:
My Rails app is hosted on Heroku and I have a GoDaddy domain
On Godaddy, I have domain forwarding already setup, and so [mysite].com gets forwarded to www.[mysite].com.
So my question - how do I get URLs which don't have 'www' in them, to redirect to the equivalent URL with 'www'?
Any ideas?
Thanks in advance!
I resolved this by setting up Cloudflare and configuring some forwarding rules.

Swagger page has uncaught exceptions flask restplus

I have a flask restplus app which has an API page documented in a swagger interface.
This page comes up happily and I can use it when it is run locally.
I have it working inside a docker container with the ProxyFix from WerkZeug. However when I put that container behind an nginx instance, I get Uncaught SyntaxError: Unexpected token '<' on swagger-ui-bundle.js . Clicking through it's indeed correct as what is being attempted to be rendered as swagger-ui-bundle.js is in fact a page of HTML, and that > is the first character of the page.
So what's going on?
How do I fix it to get the swagger page come up?
EDIT:
Turns out that the swagger was being served from /swagger, not url_prefix/swagger. This meant that the nginx config was forwarding the request to an angular front end running from /, which was serving up the html front page and not the js that was expected.
So, the solution to this is to move the swagger to be served from http://<ip>/swagger to http://<ip>/my_site/swagger. I've tried a bunch of solution but can't get any of them to serve up the swagger from anywhere but http://<ip>/swagger, which isn't helpful (and no, hardcoding the nginx config isn't the right solution as we have multiple services using potentially different versions)
So if anyone has an idea how to do that that would be amazing.

AKS Ingress navigating to a URL path returns a 404, url changes to the index.html which is the correct route?

within my ingress file i have a path set up to navigate to my app, that routes to an application,
when i go to myingresIp/pss it redirects to myingresip/index.html, so it is almost like the routing is working its just not hitting my app.
I feel like the URL still needs to keep the /app prefix.
Can any one see what could be causing this problem or suggest a way of debugging this i am pretty new to AKS/kubernetes, or if there is some kind of logs that i can access to see what the underlying issue is?
Yaml:
The page i get then i navigate to myingresIp/pss is:
pod data:

Laravel keeps removing the www from my URI, how to stop this?

i have installed a laravel application onto my hosted solution . now every time i access the site laravel is removing the www from the URI . Example www.example.com becomes example.com. i need the www to stay. please help if you can. thanks.
i have found the following.
here is the url - http://www.example.com/portal?reseller_id=1.
with this URL the www gets removed. but with the following URL it doe not .
http://www.example.com/portal/?reseller_id=1
any ideas?
Are you sure that's Laravel? The core/base Laravel code doesn't do any examining of the hostname, and should serve up the application for both the www and non-www versions of the domain. It sounds more like you have an .htaccess rule setup, or possibly your webhost has a server level configuration, that's removing the www. I'd test it out with a simple helloworld.php file before spending too much time debugging the framework.

lvh.me:3000 no longer resolving to localhost:3000 for testing subdomains in development

I followed Railscast 121 to set up subdomains for my site, www.blog.com, and got everything working in development. I could use lvh.me:3000 to access my application at both the root url www.blog.com and at the specific subdomains I set up e.g. john-doe.blog.com
After pushing to Heroku, I can no longer connect to the root url at lvh.me:3000. What could be causing this?
Symptoms in development environment:
I can access www.blog.com through localhost:3000.
I cannot access www.blog.com at lvh.me:3000. but CAN still access john-doe.blog.com.
I opened a DIFFERENT application www.secondapp.com, and the root path for this also works at localhost:3000 but not at lvh.me:3000. I have not set up any subdomains for secondapp, but tried the url john-doe.secondapp.com just in case, and for some reason, this works. Very strange...
I must have inadvertently adjusted some files, but I don't know where/how. It's completely beyond me why a completely different app would work with a subdomain for an unrelated app. Any feedback would be much appreciated.
This is because of the current godaddy outage. Once their DNS is back up, it should resolve correctly.
In the meantime, you can try editing your hosts file.

Resources