xref: /curl/docs/cmdline-opts/connect-to.md (revision 2abfc759)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: connect-to
5Arg: <HOST1:PORT1:HOST2:PORT2>
6Help: Connect to host2 instead of host1
7Added: 7.49.0
8Category: connection dns
9Multi: append
10See-also:
11  - resolve
12  - header
13Example:
14  - --connect-to example.com:443:example.net:8443 $URL
15---
16
17# `--connect-to`
18
19For a request intended for the `HOST1:PORT1` pair, connect to `HOST2:PORT2`
20instead. This option is only used to establish the network connection. It does
21NOT affect the hostname/port number that is used for TLS/SSL (e.g. SNI,
22certificate verification) or for the application protocols.
23
24`HOST1` and `PORT1` may be empty strings, meaning any host or any port number.
25`HOST2` and `PORT2` may also be empty strings, meaning use the request's
26original hostname and port number.
27
28A hostname specified to this option is compared as a string, so it needs to
29match the name used in request URL. It can be either numerical such as
30`127.0.0.1` or the full host name such as `example.org`.
31
32Example: redirect connects from the example.com hostname to 127.0.0.1
33independently of port number:
34
35    curl --connect-to example.com::127.0.0.1: https://example.com/
36
37Example: redirect connects from all hostnames to 127.0.0.1 independently of
38port number:
39
40    curl --connect-to ::127.0.0.1: http://example.com/
41