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

我的家庭web服务拓扑图 #68

Open
woodongwong opened this issue Feb 16, 2022 · 0 comments
Open

我的家庭web服务拓扑图 #68

woodongwong opened this issue Feb 16, 2022 · 0 comments

Comments

@woodongwong
Copy link
Owner

woodongwong commented Feb 16, 2022

+----------------------+
|                      |
| AAAA 2001::68f4:2eb9 |
| A    1.1.1.1         |
|                      |
+----------------------+
   www.example.com DNS


                       AWS                                                   HOME
+-----------------------------------------------+          +--------------------------------------+
|                                               |          |                                      |
| +-------------------------------------------+ |          |                                      |
| |                                           | |          |                                      |
| | server {                                  | |          |                                      |
| |     listen 80;                            | |          |                                      |
| |     server_name www.example.com;          | |          | +----------------------------------+ |
| |     location / {                          | |          | |                                  | |
| |         proxy_pass http://127.0.0.1:8080; | |          | | server {                         | |
| |     }                            +        | |          | |     listen 80;                   | |
| | }                                |        | |          | |     listen [::]:80;              | |
| |                                  |        | |          | |     server_name www.example.com; | |
| +-------------------------------------------+ |          | |     root /usr/share/nginx/html;  | |
|                     nginx          |          |          | | }                                | |
|                                    |          |          | |                                  | |
|                                    v          |          | +------+---------------------------+ |
| +----------------------------------+--------+ |          |        ^        nginx                |
| |                                           | |          |        |                             |
| | socat TCP4-LISTEN:8080,bind=127.0.0.1,\   | |          |        |                             |
| | fork TCP6:www.example.com:80              +---------------------+                             |
| |                                           | |          |                                      |
| +-------------------------------------------+ |          |                                      |
|                     socat                     |          |                                      |
|                                               |          |                                      |
+-----------------------------------------------+          +--------------------------------------+
            ipv4: 1.1.1.1                                           ipv4: none
            ipv6: 2606:4700:4700::1111                              ipv6: 2001::68f4:2eb9

家宽没有公网 ipv4,使用 AWS 做代理(ipv4 to ipv6)。
一开始使用 nginx stream,发现 nginx 并不会优先使用 ipv6,如果存在多个 DNS 记录,nginx 会轮询。
如果是 https 协议,nginx 需要开启proxy_ssl_server_name,并设置proxy_ssl_name,例如:

server {
    listen 443 ssl http2;
    server_name www.example.com;
    
    # SSL配置
    ssl_certificate ;
    ssl_certificate_key;
    # 其他配置......

    location / {
        proxy_pass https://127.0.0.1:8080;
        proxy_ssl_server_name on;
        proxy_ssl_name www.example.com;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        # 其他配置......
    }
}
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

1 participant