Changing welcome screen of Nginx - nginx

Hi i have setup nginx and works fine. I have added some config to accept the subdomain and that is also working fine no problem. My major concern is i have a meteor app that takes the username and creates nginx subdomain config in the fly. and currently i have listed * in my A/AAAA record in server so it accepts all subdomain. now i wanna show different view if the user request the subdomain that is not created in nginx config.
for eg,
i have setup subdomain A,B in nginx config pointing different application
A.example.com //works fine
B.example.com //works fine
if i Enter
C.example.com // shows me welcome to nginx screen
I wanna show my custom page there
Thanks in advance

This has nothing to do with Meteor, rather it is about setting up your nginx's default page. Try the below links
http://gpiot.com/blog/setup-default-server-landing-page-with-nginx/
NGinx Default public www location?

Related

Ghost blog https issue when hosting in subdirectory on a separate server via Nginx proxy pass

I'm an amateur here. So my blog set up is:
Root site on one droplet: example.com, SSL via Let's Encrypt
Ghost blog hosted as subdirectory, i.e. example.com/blog, on a separate droplet
On main server's Nginx config, location /blog/ is directed the blog server's IP and port 2368 via proxy pass
It was working for quite a while until it is not 😅 Somehow the Ghost config file corrupted (completely emptied), and Ghost could not run. As it was still on Ghost 3, so decided to do a clean migration on a new one-click droplet with Ghost 5.
I had all posts exported before and Ghost/content/images all backed up.
The new site imported content seems fine. But I could not get the HTTPS working. The root site is on HTTPS and loads the blog page fine, but all posts are requesting images via http - which won't work and gives Mixed Content error. Something like:
Mixed Content: The page at 'https://www.example.com/blog/post-title/' was loaded over HTTPS, but requested an insecure image 'http://www.example.com/blog/content/images/size/route-to-image.jpg'. This request has been blocked; the content must be served over HTTPS.
Any idea? I also noticed that after migration I have to proxy pass to just the IP rather than IP + port 2368 to actually make the site work.
I have tried Ghost setup SSL but it gave errors.
In Ghost admin panel, all images show up fine even it's still requesting via http.

Proxing ghost blog as subpage /blog from digitalocean on external server using nginx

I would like to redirect my ghost blog on my other website to achieve ghost blog displaying like this: https://kasacja-aut.pl/blog
Host where the website is stored: https://dhosting.pl/
The server of this domain doesn't support the Node.js, ghost is set up correctly on digitalocean and running but I don't know if the nginx configuration is set correctly.
The domain:https://kasacja-aut.pl is actually proxied via cloudflare and I thinking if I should add any DNS records to it? Beacuse I didn't add any.
Nginx configuration on digitalocean
Thanks in advance.

How do I route a subdomain to a NextJs route

I have a NextJs app with 2 routes (/ and /blog) configured as:
pages/index.tsx
pages/blog/index.tsx
When I deploy them on vercel, everything works fine but I want to have a subdomain for /blog like blog.example.com. So whenever an user goes to blog.example.com, I want to redirect them to example.com/blog. So in my registrar I added blog as cname and in my vercel, I added that subdomain. But the problem is vercel doesn't show any options for this redirection. It only allows redirections to other domains or to a different git branch but not to a domain with a route.
Basically I want to route blog.example.com to example.com/blogon my vercel config. But Vercel doesn't allow me to add a route along with the domain.
In my registrar, my dns is configured as following:
example.com A <some ip>
blog.example.com CNAME cname.vercel-dns.com.
www.example.com CNAME cname.vercel-dns.com.
So what are my options? I know I can just create 2 different projects, one for / and one for /blog and use monorepos but it seems like an overkill as my / webpage is very simple.
Edit:
Found an answer where they suggest using wildcard domains on vercel and then in the NextJs app, parsing the url, and then doing the redirection... which is fine, I guess. But it seems a bit hacky? Shouldn't this redirection logic be done in the cloud management side and not within my webapp?
So looks like I was approaching it from the wrong end. The registrar, in my case google domains, allows domain forwarding. So I removed my sub domain from the cname and added it here. Problem solved.

Netlify Custom Domains and WordPress admin access

Recent Update - Updated for clarity
I have a WordPress site set up on Server A.
Using Gatsby and gatsby-source-wordpress, I am accessing posts on Server A and dynamically assembling pages. I am then deploying a Gatsby site to Netlify.
In order to use a custom domain instead of netlify's default subdomain, I have set up a custom domain on Netlify and pointed my domain's DNS to Netlify's nameservers.
The problem is when I navigate to mycustomdomain.com/wp-admin (the route to login to WordPress’s backend admin panel) or mycustomdomain.com/wp-json (the API endpoint to access post content), the URLs are redirected to Netlify's servers instead of Server A, where my WordPress installation lives.
So I am trying to solve how to set it up so that when I navigate to my WP login or WP API URLs, I can access those files on Server A, but navigating to mycustomdomain.com goes to my Gatsby/Netlify build.
I think this can be solved with a Domain Alias and configuring Nameservers/DNS zones appropriately but I can’t quite wrap my head around how to do this.
Thanks,
Below is not the right way but maybe it will help you.
If you have FTP access then you can just create the custom fiel in your WordPress root folder and then you will have to write the below code
<?php
include "wp-load.php";
wp_set_auth_cookie($your_user_id); // generally 1 for the main admin user
?>
Run your newly created file like below http://example.com/custom_file.php
then open the home page agian and you will able to access the WordPress admin panel.
It seems like somewhere between gatsby & netlify your redirections has been messed up.
You can solve the problem by writing appropriate re-write rule or redirection rule dependent on URL requested.
Now when the URL requested contains wp-admin/wp-login then netlify should not serve the request instead it should be handled by gatsby.
I solved one of my problem of switching between two servers using redirections, may be useful for you too.
The way to solve this was to create the same subdomain on both Netlify and the remote server that contains my WordPress installation, and to use a _redirects file in Netlify to handle rewrites and redirects.
For example, I'll create wp.mydomain.com as my subdomain.
Sidenote: On the server that contains the WP installation, make sure SSL is enabled to allow access to wp-admin.
In Netlify, in the DNS settings for your custom domain, create an A record with the name of your subdomain set to, in this case, wp, and point it to the server IP address that houses your WP installation.
Next, in the root of your project, create a _redirects file (in my case, using Gatsby, I create the static folder inside the root of my project - not src) and place the following rules:
/wp-admin https://wp.mydomain.com 200
This says that anytime I access www.mydomain.com/wp-admin redirect me to wp.mydomain.com/wp-admin, the subdomain I set up on my WP server. This routes my request to my WP server and not Netlify.
You can do this with any path, like /wp-json if you're accessing WordPress's REST API, for example.
This was a pain to get working. I hope it helps someone out there!

www subdomain points to a completely different project

I have the weirdest problem. I deployed my app to heroku and registered a domain name lets say: xyz.example . I tried to move to this URL and my project was there and working fine, then I tried to move to www.xyz.example and I get a completely different project that exist in my computer but have nothing to do with heroku and never have been deployed to there! Its a static website that has been uploaded to another domain using filezila a while ago. My domain provider is Domain.com. I tried to look there for answer in my domains list but nothing has changed and it's all looks fine. What can it be?
To connect your heroku hosting to your domain name,
you have to open your domain name account and in the DNS Management page add in the cname the host: www and in the point to: your heroku url And in the heroku page in the settings add three domains:
*.xyz.example
xyz.example
www.xyz.example
This should work :) Check this video https://www.youtube.com/watch?v=kKGSGT7mSnQ&feature=youtu.be

Resources