Redirect Multiple Site Addresses/Labels (Including IP) to a Specific Site/Label in Caddyfile

Yannic Hamann

I have a server running Caddy that can be reached under the domain rv2680.1blu.de and marleneschulz.info. Both DNS A records point to the IP address 178.254.7.175. I want to make sure Caddy always redirects the user to https://marleneschulz.info.

Here is my working Caddyfile :

www.marleneschulz.info {
    redir https://marleneschulz.info
}

https://marleneschulz.info {
    root /app/marlene/shared

    proxy / django_prod:5000 {
        header_upstream Host {host}
        header_upstream X-Real-IP {remote}
        header_upstream X-Forwarded-Proto {scheme}

        except /static
    }

    log stdout
    errors stdout
    gzip
}

How can I prevent Caddy responding with e.g. 404 Site rv2680.1blu.de is not served on this interface by explicitly defining to redirect every request from rv2680.1blu.de:80, rv2680.1blu.de:443, 178.254.7.175:80, 178.254.7.175:443 and marleneschulz.info to https://marleneschulz.info?

I am also a bit confused since the docs state nothing about the www. prefix. I want to be as explicit as possible.

Matt

You can define a couple catch-all sites and redirect them:

http://, https:// {
    redir https://marleneschulz.info{uri}
}

(I added {uri} because I assume you want to preserve the URI in the redirect.)

Using http://, https:// as site addresses is the same as using :80, :443.

There's nothing special about the www prefix, either. If you wanted to enumerate all the sites you want to redirect, you would specify www.marleneschulz.info as one of them, just as with any other sites.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to redirect a domain to a different IP if accessed by a specific port?

分類Dev

Assembly the site including children

分類Dev

How to Redirect marked packets on multiple ports to one IP Address

分類Dev

redirect in php in the middle of the site

分類Dev

including specific RxJS operators

分類Dev

Redirect entire site to a sub folder

分類Dev

Redirect to another site while 404

分類Dev

VPS IP address for local site

分類Dev

including cpp files multiple times

分類Dev

My wordpress site redirect me to my localhost

分類Dev

Import site-specific data

分類Dev

Rails - Redirect to specific record page

分類Dev

.htaccess Do not Redirect Specific Words

分類Dev

Delete contents of a string including and after a specific word

分類Dev

Create React App Blank Page when including on existing site

分類Dev

複数のサイトアドレス/ラベル(IPを含む)をCaddyfileの特定のサイト/ラベルにリダイレクトする

分類Dev

How to redirect a URL to a custom IP address?

分類Dev

.htaccess Redirect all users to subfolder EXCEPT for IP

分類Dev

Redirect IP to Another Page Using Htaccess

分類Dev

VPS with multiple ip and iptables

分類Dev

Redirect requests to my external IP/port to a different external IP/port?

分類Dev

nginx redirect multiple servers to SSL

分類Dev

EF.Functions.Contains including multiple keywords

分類Dev

including Multiple headers in Code::Blocks error

分類Dev

Virtualbox forward specific ip to guest

分類Dev

Bypass Apache Authentication for specific IP

分類Dev

PHP Regex match specific site url with params

分類Dev

Allow 'block objects' from a specific site

分類Dev

nginx redirect old site urls and modify 1 language suffix only

Related 関連記事

  1. 1

    How to redirect a domain to a different IP if accessed by a specific port?

  2. 2

    Assembly the site including children

  3. 3

    How to Redirect marked packets on multiple ports to one IP Address

  4. 4

    redirect in php in the middle of the site

  5. 5

    including specific RxJS operators

  6. 6

    Redirect entire site to a sub folder

  7. 7

    Redirect to another site while 404

  8. 8

    VPS IP address for local site

  9. 9

    including cpp files multiple times

  10. 10

    My wordpress site redirect me to my localhost

  11. 11

    Import site-specific data

  12. 12

    Rails - Redirect to specific record page

  13. 13

    .htaccess Do not Redirect Specific Words

  14. 14

    Delete contents of a string including and after a specific word

  15. 15

    Create React App Blank Page when including on existing site

  16. 16

    複数のサイトアドレス/ラベル(IPを含む)をCaddyfileの特定のサイト/ラベルにリダイレクトする

  17. 17

    How to redirect a URL to a custom IP address?

  18. 18

    .htaccess Redirect all users to subfolder EXCEPT for IP

  19. 19

    Redirect IP to Another Page Using Htaccess

  20. 20

    VPS with multiple ip and iptables

  21. 21

    Redirect requests to my external IP/port to a different external IP/port?

  22. 22

    nginx redirect multiple servers to SSL

  23. 23

    EF.Functions.Contains including multiple keywords

  24. 24

    including Multiple headers in Code::Blocks error

  25. 25

    Virtualbox forward specific ip to guest

  26. 26

    Bypass Apache Authentication for specific IP

  27. 27

    PHP Regex match specific site url with params

  28. 28

    Allow 'block objects' from a specific site

  29. 29

    nginx redirect old site urls and modify 1 language suffix only

ホットタグ

アーカイブ