Netlify - Multiple apps under a single custom domain aka routing - netlify

I am using netlify and would like to build 2 apps, which basically create static /dist folders.
Now I would like netlify to manage routing for example app.com/app1 and app.com/app2 to point to the two various builds.
Is this possible via the .toml file?

I've already answered a question about an identical use case here: Reverse proxy same naked domain to different hosts
While that answer refers to cloudflare because the question did, the answer is how to do it using just Netlify. I use the _redirects syntax in the answer instead, but the workflow is the same:
deploy two Netlify sites to make two builds. One will be app.com and one will be your subsite. The multiple build commands, you will only be able to control with two toml files assuming that you have two repos. If they are subdirs in the same repo, the config will have to be in netlify's UI (also possible via API) instead.
(reverse) proxy from the main site to the subsite for the subdirectory
using toml syntax like the below on the main site (app.com):
[[redirects]]
from = "/subsite/*"
to = "https://other-netlify-site.netlify.com/subsite/:splat"
status = 200
force = true

Related

netlify Deployment issue: netlify.toml settings for SPA

Disclaimer: I would ask this using either a.) some sort of support system on Netlify, b.) on a Netlify live chat session or c.) via their support community but a.) they don't let you, b.) they don't have one and c.) you can't currently create accounts or authorize from Netlify itself. (Seems like as an organisation, they don't really understand what would really nudge you into making you pay for a service).
Anyways, I am having an issue with deploying an Vue.js SPA with VueRouter via a netlify.toml configuration. The issue is, all internal routing is not being handled by the SPA. My solution has always been to stick a netlify.toml config file in the root of the repository that I am deploying from, with the following:
# The following redirect is intended for use with most SPAs that handle routing internally.
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
Yet, every internal route I visit gives me:
The exact same repo, but deployed on my personal plan 4 months ago (which has the same netlify.toml config in the same location) works fine. The application is also working on the current deployment branch locally. The routing is not broken. Has anyone else suffered with this inconsistent approach to redirects with Netlify?
So, my specific fix was to do the following:
Add a _redirects file to the public directory of my Vue application, then:
# The following redirect is intended for use with most SPAs that handle routing internally.
/* /index.html 200
Inside that file.
So for me, netlify.toml configuration for redirects is stil broken.
I am seeing exactly this behaviour as well. The netlify.toml contains:
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
But doesn't work. The deployment summary even shows that netlify didn't pick up the redirect config at all:
No redirect rules processed
This deploy did not include any redirect rules. Learn more about redirects.
I just faced this issue like 2hrs ago from now, but the netlify.toml is working fine for me. Make sure you have set the public directory in your netlify setting to '/' (exactly where your netlifly.toml resides) instead of blank or anything else.

Creating custom domain names for api

I have a web server using cpanel and I would like to use a custom domain on one folder for an api. So if I created a folder called api in the public_html folder then the path to that folder would be www.example.co.uk/api/(some php file). How could I change it so the folder would become a custom domain of api.example.co.uk/api/(some php file).
I have looked at a few options but don't really know the best way. I have tried to add a htaccsess file to the api folder and then create a rewrite rule to rewrite the www to api.
I also then looked at creating sub domains with the path to the api folder.
I have read that creating a A record on the server could work but I'm not quite sure how to do this. I know it can be done as most apis use some custom domain like facebooks graph api. (i.e https://graph.facebook.com/youtube/)
This will depend on if you have access to make DNS records for your root domain, example.co.uk. For example right now www. is a CNAME or A record (depends on how your web server is set up), that resolves to the address of your web server. If you made an identical record but named it api. (api. IN A ip-of-webserver), then api.example.co.uk would do the same thing that www.example.co.uk does. This is kind of pointless if they go to the same web server though, the /api/ part of the route makes it clear enough that the routes are for the api. What subdomains like facebook's are doing are pointing to a completely different application, and different web servers. For example, a company may have domains like mail.company.com, portal.company.com, sso.company.com, that all resolve to the address of different web servers for the different apps they have, but in this case it sounds like you are running one web server which is fine, you can have one web server be the api as well as serve the website.

[Gitlab]Where can I find Gitlab Pages hosted on my private Gitlab instance?

I tried to set up Gitlab Pages, until now I finished uploading my static website files👇
Uploading artifacts...
coverage/lcov-report: found 77 matching files
Uploading artifacts to coordinator... ok id=1038 responseStatus=201 Created token=QXJjgkf2
But I got no idea where my page hosted.
I took a glance at this documentation but it was still vague to me.
I have a private Gitlab instance.
My Gitlab entry is under http://abc.def.com (I configured a type A DNS to my host IP 111.111.111.111, a reverse proxy pointing at localhost:9000).
My project project1 is under my team team1.
I have also configured DNS http://team1.abc.def.com to 111.111.111.111 , and there is a nginx reverse proxy on my server which http://team1.abc.def.com -> localhost:9000.
I assume I should see my static page available on http://team1.abc.def.com/project1 , but nothing was there. Where exactly are my pages hosted?
You have to activate the pages feature. In your gitlab.rb:
pages_external_url "IP_OF_YOUR_GITLAB"
gitlab_pages['enable'] = true
There is a tutorial: https://www.youtube.com/watch?v=dD8c7WNcc6s&feature=youtu.be
And the complete documentation: https://docs.gitlab.com/ce/administration/pages/index.html
You'll need to ask your sysadmin under which wildcard domain Pages is served: https://docs.gitlab.com/ce/user/project/pages/getting_started_part_one.html#gitlab-pages-domain
Then you'll know where your site was deployed to.
Example: on GitLab.com, all Pages domains are served under *.gitlab.io, therefore, your website will be deployed to username.gitlab.io (user/group site) or to username.gitlab.io/project-name (project website).
You need to find out the wildcard domain of your GitLab instance and replace gitlab.io with it.
See also: Pages' limitations: https://docs.gitlab.com/ce/user/project/pages/introduction.html#limitations
pages_external_url is the url of your website
You can set up a git-runner to pick the work for publishing your website. In this part you need to deal with .gitlab-ci.yml file
For the gitpage URL, you can find it under setting -> pages, there should be a URL for the website. Usually is under namespace.example.com/projectname.
If you didn't see the page under the setting, it is usually a configuration issue. You just need to enable it, and re-congiure the gitlab.
For gitlab pages to work, you need to put your website files (html, CSS etc.) in a folder named public.
Update your .gitlab-ci.yml file with something like the following
pages:
script:
- mv coverage/lcov-report public
artifacts:
paths:
- public
Also, remember to name the job in question pages

Several Starcounter applications on one server with many domains

I have seen no built in support in Starcounter to do site bindings, for example in the same way Internet Information Server where you can route calls to a specific site depending on domain name used as per the picture below. Is there any recommended way to how to work do this?
In Starcounter you can setup multiple domains in the ReverseProxies configuration section of the scnetworkgateway.xml file.
Example:
<ReverseProxy>
<DestinationIP>127.0.0.1</DestinationIP>
<DestinationPort>8080</DestinationPort>
<StarcounterProxyPort>80</StarcounterProxyPort>
<MatchingHost>my.website.com</MatchingHost>
</ReverseProxy>
Read more on starcounter.io - Reverse proxy functionality.

Share a web project between subdomains on Azure Websites

I would like to create the following scenario in my web project, but as I am not pro web developer I don't know how to handle this.
Let's assume that I have project with main domain:
http://foobar.com and on this I have a links to the following subdomains:
http://xx.foobar.com
http://yy.foobar.com
I would like to that every site hosted on subdomains used the same code with only one different parameter sent to the subdomain from main page. This parameter will be a JavaScript variable. I am using Azure Web Sites from my project. The main question here is how to manage the code (now I am using Continuos Integration with GitHub) through these subdomains (the source code for every subdomain would be the same, except this one variable). Where should I start to search / read?
Are you passing any value for the parameter? Or is it just a static parameter? If it's static, you could possibly use JavaScript code to read the subdomain name in the URL.
Not sure what language you're using on the server, but you should also able to read the subdomain via server-side code.
But if its value is dynamic, the main page with the links can generate a QueryString parameter to pass along in the URL. Your implantation will vary depending on what language you've selected.
UPDATED, with additional info:
When you say "share the project source code between subdomains", do you mean that you want to deploy the same web app to multiple endpoints?
If so, you can create a separate Web App in Azure (formerly known as Azure Web Site) for each corresponding subdomain, and set up your source control to deploy to both of them whenever you check in your code.
References:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/
https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
Since you have no server-side code, I'm using you have only HTML/JavaScript/CSS files. So, you can write JavaScript code to read the parameter from the URL.
References:
http://www.w3schools.com/jsref/prop_loc_href.asp
http://www.w3schools.com/jsref/prop_loc_pathname.asp
http://www.cssmojo.com/the_location_object/
As I mentioned earler, you would set up the links on the main index page to pass in QueryString parameters:
e.g.
Link 1: http://sub1.mywebsite.com/?param1
Link 2: http://sub2.mywebsite.com/?param2
Hope that helps!
First, make sure you point your domain to your azure website using wildcard (references)
Second, in your html head, find the subdomain using javascript and assign in to the variable you want to use
var full_url = window.location.host; // e.g. subdomain.host.com
var parts = full.split('.'); // split it
var subdomain = parts[0];
now you can use the subdomain variable to change your website based on subdomain value (e.g. change the content)

Resources