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

Apache反向代理 #1661

Closed
oreeke opened this issue Mar 29, 2024 · 1 comment
Closed

Apache反向代理 #1661

oreeke opened this issue Mar 29, 2024 · 1 comment

Comments

@oreeke
Copy link
Contributor

oreeke commented Mar 29, 2024

可能现在用Apache的人少,没看到完整方案,顺手发一个希望有帮助。

以下配置基于Apache 2.4.57

<VirtualHost *:443>
    # 域名
    ServerName example.com
    ServerSignature Off

    # 错误日志级别、路径
    LogLevel warn
    ErrorLog /var/log/apache2/error.log

    # 访问日志路径、格式
    CustomLog /var/log/apache2/access.log "vhost_combined"

    # SSL相关设置
    Protocols h2
    SSLEngine on
    SSLProtocol -all +TLSv1.2 +TLSv1.3    # 禁用旧版TLS协议
    SSLCertificateFile /etc/ssl/certs/example.com/example.crt
    SSLCertificateKeyFile /etc/ssl/private/example.com/example.key
    SSLCACertificateFile /etc/ssl/certs/example.com/root_bundle.crt

    # 安全标头,根据需要修改或添加
    Header always set X-XSS-Protection "1; mode=block"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "DENY"
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains;"    # 开启SSL才需要

    # 反向代理设置,使用本项目配置的端口,需要用到websocket,所以做一下协议升级
    ProxyPass "/" "http://localhost:1234/" upgrade=websocket
    ProxyPassReverse "/" "http://localhost:1234/"

    # 为了避免Gradio登录出现的BUG,用其他认证方案代替
    # 以下配置使用Apache自带的 [mod_auth_digest] 模块,安全性一般
    # 也可以使用 [mod_auth_basic] 模块,前提是开启SSL以确保传输安全
    # 推荐配合或更换高级认证模块,比如OIDC、LDAP之类的
    <Location />
        AuthType Digest
        AuthName realm
        AuthDigestDomain /
        AuthDigestProvider file
        AuthUserFile /path/to/password file
        Require valid-user
    </Location>
</VirtualHost>
@binary-husky
Copy link
Owner

非常感谢,我在wiki里面添加了到这里的链接:

https://github.com/binary-husky/gpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97

@oreeke oreeke closed this as completed Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants