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

分享一个ui界面使用https的方法 #809

Open
ericjuice opened this issue Dec 16, 2023 · 4 comments
Open

分享一个ui界面使用https的方法 #809

ericjuice opened this issue Dec 16, 2023 · 4 comments

Comments

@ericjuice
Copy link

ericjuice commented Dec 16, 2023

使用nginx对ui前端以及clash的api都进行反向代理即可。然后通过二级域名进行https。
配置如下. 注意 /的使用很重要.

location ^~ /api/ {
    proxy_pass http://127.0.0.1:9090/; 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header REMOTE-HOST $remote_addr; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_http_version 1.1; 
    add_header Cache-Control no-cache; 
}
location ^~ / {
    proxy_pass http://127.0.0.1:9090/ui/; 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header REMOTE-HOST $remote_addr; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_http_version 1.1; 
    add_header Cache-Control no-cache; 
}

然后在ui里输入https://你的外网IP/api, 填入密码(如果有)就可以了

@ericjuice ericjuice changed the title ui 分享一个ui界面使用https的方法 Dec 16, 2023
@KiritanTakechi
Copy link

config server 'clash'
    option server_name '****.com'
    list listen '9990 ssl'
    list listen '[::]:9990 ssl'
    list listen '9990 quic reuseport'
    list listen '[::]:9990 quic reuseport'
    option ssl_protocols 'TLSv1.3'
    option ssl_certificate ''
    option ssl_certificate_key ''
    option ssl_trusted_certificate ''
    option ssl_prefer_server_ciphers 'off'
    option ssl_ciphers ''
    option ssl_session_tickets 'on'
    list include '@location[clash_api]'
    list include '@location[ui_api]'

config location 'clash_api'
    option class 'proxy_pass'
    option url 'http://localhost:9090/'
    list match '/api/'
    list option 'proxy_set_header Host $host'
    list option 'proxy_set_header X-Real-IP $remote_addr'
    list option 'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for'
    list option 'proxy_set_header REMOTE-HOST $remote_addr'
    list option 'proxy_set_header Upgrade $http_upgrade'
    list option 'proxy_set_header Connection "upgrade"'
    list option 'proxy_set_header X-Forwarded-Proto $scheme'
    list option 'proxy_http_version 1.1'
    list option 'add_header Cache-Control no-cache'

config location 'ui_api'
    option class 'proxy_pass'
    option url 'http://localhost:9090/ui/'
    list match '/'
    list option 'proxy_set_header Host $host'
    list option 'proxy_set_header X-Real-IP $remote_addr'
    list option 'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for'
    list option 'proxy_set_header REMOTE-HOST $remote_addr'
    list option 'proxy_set_header Upgrade $http_upgrade'
    list option 'proxy_set_header Connection "upgrade"'
    list option 'proxy_set_header X-Forwarded-Proto $scheme'
    list option 'proxy_http_version 1.1'
    list option 'add_header Cache-Control no-cache'

为什么这样配置连接9990/api显示Not Found

@ericjuice
Copy link
Author

config server 'clash'
    option server_name '****.com'
    list listen '9990 ssl'
    list listen '[::]:9990 ssl'
    list listen '9990 quic reuseport'
    list listen '[::]:9990 quic reuseport'
    option ssl_protocols 'TLSv1.3'
    option ssl_certificate ''
    option ssl_certificate_key ''
    option ssl_trusted_certificate ''
    option ssl_prefer_server_ciphers 'off'
    option ssl_ciphers ''
    option ssl_session_tickets 'on'
    list include '@location[clash_api]'
    list include '@location[ui_api]'

config location 'clash_api'
    option class 'proxy_pass'
    option url 'http://localhost:9090/'
    list match '/api/'
    list option 'proxy_set_header Host $host'
    list option 'proxy_set_header X-Real-IP $remote_addr'
    list option 'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for'
    list option 'proxy_set_header REMOTE-HOST $remote_addr'
    list option 'proxy_set_header Upgrade $http_upgrade'
    list option 'proxy_set_header Connection "upgrade"'
    list option 'proxy_set_header X-Forwarded-Proto $scheme'
    list option 'proxy_http_version 1.1'
    list option 'add_header Cache-Control no-cache'

config location 'ui_api'
    option class 'proxy_pass'
    option url 'http://localhost:9090/ui/'
    list match '/'
    list option 'proxy_set_header Host $host'
    list option 'proxy_set_header X-Real-IP $remote_addr'
    list option 'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for'
    list option 'proxy_set_header REMOTE-HOST $remote_addr'
    list option 'proxy_set_header Upgrade $http_upgrade'
    list option 'proxy_set_header Connection "upgrade"'
    list option 'proxy_set_header X-Forwarded-Proto $scheme'
    list option 'proxy_http_version 1.1'
    list option 'add_header Cache-Control no-cache'

为什么这样配置连接9990/api显示Not Found

注意填api那个框要用外网ip/域名,而不是localhost。如果是这样还报错那就不清楚咯,没怎么用过这个(应该是openresty吧?)

@KiritanTakechi
Copy link

是的就是填的域名,能打开ui但是ui连不上clash,这个是openwrt 的uci配置

@KiritanTakechi
Copy link

ui里面连接显示不是连接失败而是未找到,挺奇怪的

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