Score:0

Apache Reverse Proxy สำหรับอุโมงค์ SSH

ธง pt

ฉันต้องการตั้งค่า Apache reverse proxy สำหรับอินสแตนซ์ Home-Assistant (hass) ที่ทำงานอยู่ในเครือข่ายท้องถิ่นของฉัน

ฉันทันเนลทราฟฟิกของอินสแตนซ์ hass ในเครื่องไปยังเซิร์ฟเวอร์ระยะไกลด้วย ssh -N [email protected] -R 8123:localhost:8123.

ตอนนี้ฉันพยายามตั้งค่า reverse proxy ธรรมดาใน Apache:

<VirtualHost *:443>
    ServerName hass.example.com

    SSLEngine On

    # If you manage SSL certificates by yourself, these paths will differ.
    SSLCertificateFile fullchain.pem
    SSLCertificateKeyFile privkey.pem

    SSLProxyEngine on
    SSLProxyProtocol +TLSv1.2 +TLSv1.3
    SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyVia On
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
    
            
    # Proxy all traffic to hass
    ProxyPass / http://localhost:8123/ nocanon
    ProxyPassReverse / http://localhost/
    ErrorLog ${APACHE_LOG_DIR}/hass.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/hass.example.com-access.log combined
    <IfModule security2_module>
        SecRuleEngine off
    </IfModule>
</VirtualHost>

<VirtualHost *:80>
    ServerName hass.example.com

    Redirect permanent / "https://hass.example.com"

    ErrorLog ${APACHE_LOG_DIR}/hass.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/hass.example.com-access.log combined
</VirtualHost>

น่าเศร้าถ้าฉันพยายามที่จะเปิด hass.example.comเบราว์เซอร์ตอบสนองด้วย 400: คำขอไม่ถูกต้อง.

djdomi avatar
za flag
คุณต้องการ guacamole, apache ไม่สามารถจัดการ ssh ได้ด้วยตัวเอง
us flag
`hass` ของคุณได้รับการกำหนดค่าให้เรียกใช้ที่ชื่อโดเมน `hass.example.com` หรือไม่
Toorero avatar
pt flag
@Tero Kilkanen ไม่มันเป็นเพียงคอนเทนเนอร์นักเทียบท่าวานิลลาที่ฟังบน localhost
Toorero avatar
pt flag
@djdomi ฉันไม่ได้ใช้ SSH กับ Apache ฉันเพิ่งใช้พอร์ตในเครื่อง (ผ่าน SSH) `8123` และแค่ต้องการพร็อกซี
us flag
`hass` ควรมีการกำหนดค่าสำหรับชื่อโดเมนรูท คุณต้องตรวจสอบว่า
Toorero avatar
pt flag
จริง ๆ แล้วฉันไม่เข้าใจว่าทำไมสิ่งนี้ถึงเป็นปัญหาเพราะมันเป็นพร็อกซี transperent พร็อกซีร้องขอเฉพาะ `localhost:8123` ฉันควรเพิ่ม: ถ้าฉันทำอะไรตามบรรทัดของ `ssh -L 8123:localhost:8123 -N [email protected]` ฉันสามารถเข้าถึง `localhost:8123` บนเครื่องที่ฉันใช้คำสั่งได้อย่างง่ายดาย ดังนั้นอุโมงค์ SSH จึงใช้งานได้
Toorero avatar
pt flag
@TeroKilkanen ฉันยังพยายามเปิดพอร์ต 8123 สู่สาธารณะ และฉันสามารถเข้าถึงอินสแตนซ์ hass ของฉันผ่านทาง example.com:8123 แต่นั่นไม่ใช่สิ่งที่ฉันต้องการจริงๆ เนื่องจากฉันต้องการกำหนดเส้นทางการรับส่งข้อมูลผ่านพร็อกซี Apache ฉันไม่คิดว่าชื่อโดเมนรูทนั้นสามารถกำหนดค่าได้ในทางใดทางหนึ่งและไม่สำคัญ
Score:0
ธง pt

ทุกอย่างเดือดลงไป Home-Assistant บล็อกการย้อนกลับพร็อกซี ความพยายามและสิ่งที่คุณต้องทำ ร้องขอพร็อกซี websocket เช่นกัน.

ปรับ hass-config (config/configuration.yaml):

http:
  use_x_forwarded_for: จริง
  trust_proxy:
  - ::1
  - 127.0.0.1
  ip_ban_enabled: จริง
  login_attempts_threshold: 5

การกำหนดค่า Apache:

<VirtualHost *:443>
    ServerName hass.example.com

    SSLEngine On

    # If you manage SSL certificates by yourself, these paths will differ.
    SSLCertificateFile fullchain.pem
    SSLCertificateKeyFile privkey.pem

    SSLProxyEngine on
    SSLProxyProtocol +TLSv1.2 +TLSv1.3
    SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyVia On
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
    
            
    # Proxy all traffic to hass
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket
    RewriteRule /(.*) ws://localhost:8123/$1 [P]
    RewriteCond %{HTTP:Upgrade} !=websocket
    RewriteRule /(.*) http://localhost:8123/$1 [P]
    ProxyPassReverse / http://localhost:8123


    ErrorLog ${APACHE_LOG_DIR}/hass.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/hass.example.com-access.log combined
    <IfModule security2_module>
        SecRuleEngine off
    </IfModule>
</VirtualHost>

<VirtualHost *:80>
    ServerName hass.example.com

    Redirect permanent / "https://hass.example.com"

    ErrorLog ${APACHE_LOG_DIR}/hass.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/hass.example.com-access.log combined
</VirtualHost>

โพสต์คำตอบ

คนส่วนใหญ่ไม่เข้าใจว่าการถามคำถามมากมายจะปลดล็อกการเรียนรู้และปรับปรุงความสัมพันธ์ระหว่างบุคคล ตัวอย่างเช่น ในการศึกษาของ Alison แม้ว่าผู้คนจะจำได้อย่างแม่นยำว่ามีคำถามกี่ข้อที่ถูกถามในการสนทนา แต่พวกเขาไม่เข้าใจความเชื่อมโยงระหว่างคำถามและความชอบ จากการศึกษาทั้ง 4 เรื่องที่ผู้เข้าร่วมมีส่วนร่วมในการสนทนาด้วยตนเองหรืออ่านบันทึกการสนทนาของผู้อื่น ผู้คนมักไม่ตระหนักว่าการถามคำถามจะมีอิทธิพลหรือมีอิทธิพลต่อระดับมิตรภาพระหว่างผู้สนทนา