Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add domain alias #314

Closed
etienne-dldc opened this issue Nov 6, 2018 · 16 comments
Closed

[Feature Request] Add domain alias #314

etienne-dldc opened this issue Nov 6, 2018 · 16 comments

Comments

@etienne-dldc
Copy link
Contributor

Hi 👋

I would like to be able to add a new domain on an app as an alias that would redirect to the main domain.

Example:

  • I have an app on myapp.captain.myserver.com
  • I add a domain myapp.com
  • I add an alias www.myapp.com (this redirect www.myapp.com to myapp.com with a 302)
@githubsaturn
Copy link
Collaborator

It is already possible. You can do this in multiple ways:

  1. You can add as many "custom" domains as you want to your app. i.e., you can have myapp.com www.myapp.com and anything else, all resolving to your myapp.captain.myserver.com
  2. if you want a redirect for sure, you can do this in two ways:
    2a) Do it at the application level. e.g., in ExpressJS, res.redirect('myapp.com');
    2b) Create a dummy app, connect www.myapp.com and redirect in nginx level to myapp.com. You don't even need to deploy anything.

@etienne-dldc
Copy link
Contributor Author

My point was that it would be nice to have that without having to either set it up at the application level or having a dummy app with custom nginx config...

@githubsaturn
Copy link
Collaborator

githubsaturn commented Nov 8, 2018

I see. I'll reopen this for now. But I am not sure how much value this feature adds considering that it's already possible, only with some nginx modifications. Anyways, we'll leave it open for now and will decide later.

@tuefekci
Copy link

tuefekci commented Dec 14, 2018

So i thought a bit more about it and its works atleast in my setup perfectly via nginx configuration in the web interface you can add it to your projects or the global configuration depending on your usecase.

server {
	listen 80;
	listen [::]:80;

	server_name www.myapp.com;
	return 301 http://myapp.com$request_uri;
}

@elmiguedev
Copy link

elmiguedev commented Feb 21, 2019

Hi! i have a question. I was created a new domain for one of my apps.

newdomain.tk

But, when i create a CNAME alias which redirect to myapp.captaindomain.tk, the browser URL don't stay the same, it changes to "myapp.captaindomain.tk" again.

Is there any way to achieve this redirection without changing the browser URL? (i mean, i want browser's url stay "newdomain.tk")

thnks!

@githubsaturn
Copy link
Collaborator

Don't use CNAME redirection. Use A record:

  • Set newdomain.tk pointing to xxx.xxx.xxx.xxx (your server IP)
  • Login to CapRover web dashboard and "Connect New Domain" with newdomain.tk
  • Now go to browser newdomain.tk, this should not redirect.

Let me know if you are still having issues.

@natsumi
Copy link

natsumi commented May 30, 2019

@tuefekci have you been able to get that working with force https on? I can't seem to get it working even with changing it to this

server {
	listen 443;
	listen [::]:443;

	server_name www.myapp.com;
	return 301 https://myapp.com$request_uri;
}

@iznotek
Copy link

iznotek commented Nov 18, 2019

hye everyone, thanks a lot for this so good and easy to use caprover project... but, hehe, i got the same pb as describe and this:

Don't use CNAME redirection. Use A record:
Set newdomain.tk pointing to xxx.xxx.xxx.xxx (your server IP)
Login to CapRover web dashboard and "Connect New Domain" with newdomain.tk
Now go to browser newdomain.tk, this should not redirect.

does not work at all, i get the domain mydomain.life redirecting... i'm sad...
all is using https... it's just a wordpress auto install with last caprover version on a vps...
any ideas...

@iznotek
Copy link

iznotek commented Nov 18, 2019

also if www.mydomain.life is set on the adress bar, it fully failed with blue screen "Nothing here yet :/"
with www.mydomain.life same A record as mydomain.life on ip server... ?

@valatonload
Copy link

Hi folks, one more voice here to voice the fact that the connect a domain feature isn't behaving as intended.

You can get myotherdomain.com to be an alias of to app.cpt.domain.com but ultimately, you'll always be redirected to app.cpt.domain.com
That sorts of defeat the purpose of the alias.

@s-kris
Copy link

s-kris commented Mar 19, 2020

@githubsaturn An option to set preferred domain for an app will be extremely helpful.

@funkhauscreative
Copy link

Can someone please post a working redirect with ssl enabled? I tried a lot of server combinations in the NGINX config of the app, but still no luck.

I just want the www.domain.com to redirect to domain.com.

@sdzyba
Copy link

sdzyba commented Aug 26, 2020

@natsumi
@funkhauscreative

try this

server {
  listen 80;
  listen 443;
  server_name www.<%-s.publicDomain%>;
  return 301 $scheme://<%-s.publicDomain%>$request_uri;
}

<%-s.publicDomain%> is replaced by CapRover with the domain name, but you may just replace the value by yourself with, for example, myapp.com

@IMarty
Copy link

IMarty commented Nov 6, 2020

That still not work :/
What could be a better nginx.conf for the root setting in order to have my server responding with the good app ?
I have an app "my-wordpress.my-domain.fr" that is working fine with https !
I own a domaine "my-wordpress-example.fr"
I have set the DNS to point to the server
But right now, when I visite the url I get a message "Nothing here yet :/ "
How can I make :

  1. "my-wordpress-example.fr" shows the app my-wordpress.
  2. have "my-domain.fr" (root level) shows/redirect a specific app from the subdomain.

@githubsaturn
Copy link
Collaborator

Go to your apps > wordpress > Connect a new domain

You can see it in action in the demo website under "demo-nodejs"
https://captain.server.demo.caprover.com

image

PS: this is unrelated to this thread, for further questions please open a new issue.

@githubsaturn
Copy link
Collaborator

Done. It'll be part of the next release:

image

githubsaturn added a commit to caprover/caprover-frontend that referenced this issue May 9, 2023
* Added redirect to specific domain caprover/caprover#314

* Fixed linter
githubsaturn added a commit to caprover/caprover-frontend that referenced this issue Jul 4, 2023
* Added redirect to specific domain caprover/caprover#314

* Fixed linter
dummy-head added a commit to dummy-head/typescript-captain that referenced this issue Jul 16, 2023
githubsaturn added a commit that referenced this issue Aug 27, 2023
* Expanding the scope of official docker registry auth

* Pulling image before updating

* support any domain and ssh-user when using git deploy

* additional tests for sanitizeRepoPathSsh()

* Refactoring PR

* Enabling gzip for the dashboard

* Enabling gzip for the dashboard

* Better threshold for gzip

* Added clarification about /captain for developing on Mac OS catalina or above

* Added Postman collcetion

* fix: provide configured captainSubDomain to frontend

* Force rebuild to check the test quality

* Disabling test temporarily to unblock pipeline

* Retry tests

* Retry tests

* Retry tests

* Retry tests

* Retry tests

* Retry tests

* Retry tests

* Adding support for overwriting app defaults NGINX config

* chore(deps): move dev deps

* Throw error with status code on empty namespace

When throwing an error without status code it resolve in a 500 error.
Using an error with a status code resolve in more explicit errors.

* chore: upgrade caprover/netdata docker image to the latest version

* Update dockerfile-captain.edge

* Fix README.md

* Update README.md

* corrected error print grammar

* Trim the customdomain before adding it

Domains are frequently copied and pasted and may therefore end with spaces or tabs.

* Changed clone commands to use ---recurse-submodules

* Fixed formatting

* fix: allow dot in repo name

* fix: allow substring 'git' & trailing slash in repo name

* fix: trailing slash must immediately follow .git

* test: add tests for . and .git in repo name

* test: only run backup tests in CI

* documentation(docker): upgrade docker documentation for macos

Fix docker documentation to match to the new docker interface for macos

* feat(macOs): add support for macOs Catalina and above

* Updating change logs since the last release

* Update CHANGELOG.md

* fix: Prettify code

* updated to node-18

* Fix app config update for global mode services

* Temporarily fixing the build

* Add network override option

* Moving curl up to see if the build fails again

* Updating packages to see if it fixes the build

* Update publish_edge.yml

* Upped all files to node 18

* Upped all files to node 18

* app tags

* Update CHANGELOG.md

* Added redirect to specific domain #314 (#1744)

* See #1744

* Update CHANGELOG.md

* removed fixed FE hash from edge

* Fixing edge

* Consolidated release build

* Update DockerRegistryHelper.ts (#1778)

See here: #1777 (comment)

* fixed redirect domains

* Fixed env vars for netdata

* Squash merge pro

* Updated terms

* Updated contribs

* Updated readme

* Updated changelog

* Added openssl to alpine images

* changed base domains

* Fixed #1822

* Fixed 8949e18

* changed base domains

* Change priority of the pro

* Added feature flags

* Added feature flags

* Added feature flags

* Convert flags to singleton

* Convert flags to singleton

* Fixed feature flags

* Fixed feature flags

* Fixed feature flags

* Updated terms

* Updated terms

* Reordered changelog for the next release

* Upped the version

* Update TERMS_AND_CONDITIONS.md

* updated github actions

---------

Co-authored-by: Nico Beierle <nico.beierle@gmail.com>
Co-authored-by: Nilesh <git@nileshtrivedi.com>
Co-authored-by: Jonas <30421456+jonaskuske@users.noreply.github.com>
Co-authored-by: Jan-Eric Winkelmann <jan@funkhaus.io>
Co-authored-by: c43721 <rlahman.game@gmail.com>
Co-authored-by: djexvr <ruhlmannvianney@gmail.com>
Co-authored-by: Radosław Kłos <radoslaw@klos.dev>
Co-authored-by: Camille Louédoc-Eyriès <camille.eyries@gmail.com>
Co-authored-by: Fractal-Tess <vgfractal@gmail.com>
Co-authored-by: Thomas Ghysels <info@thomasg.be>
Co-authored-by: Logstor <a.rottger_rydahl@live.dk>
Co-authored-by: Jonas Kuske <mail@jonaskuske.com>
Co-authored-by: Simon Belbeoch <simon.belbeoch@ln1.eu>
Co-authored-by: Ash <84814+VoidMonk@users.noreply.github.com>
Co-authored-by: drmrbrewer <michael@thebrewerfamily.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants