Deploy ChatGPT Next Web to Azure App Service with Individual Account Login in 3...
source link: https://edi.wang/post/2023/5/18/deploy-chatgpt-next-web-to-azure-app-service-with-individual-account-login-in-3-minutes
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Deploy ChatGPT Next Web to Azure App Service with Individual Account Login in 3 minutes
Original
Edi Wang
5/18/2023, 8:09:52 AM
148 Reads
Background
ChatGPT Next Web is a popular ChatGPT web UI project. It requires only your Open API key to deploy a web site that can be deployed to your own server, then you can have the same chat experience without going to the official Open AI website. This is typically used to work around some network or regional restrictions.
However, the official repo of ChatGPT Next Web did not provide a one-click install for Azure, and the developer is not planning to provide a built-in login feature to limit access to the website. I would like to solve both issues by Azure, my goal is:
- Deploy ChatGPT Next Web to Azure without creating a VM
- Add access control that requires individual account to login to use ChatGPT without modifying any code
- Complete these tasks in 3 minutes
Let's see how to do this.
Create Azure App Service
The official ChatGPT Next Web provides a Docker image. This is how I can run it on Azure without VM. Azure has many PaaS ways to deploy Docker containers:
- Azure App Service
- Azure Container Instance
- Azure Container App
I choose App Service because it has built in Authentication features that I will use in the next step.
Go to Azure Portal, create a new Web App, select Docker Container + Linux in instance details.
For pricing plans, as I tested, Basic SKUs are enough for a few users, you can choose a higher SKU if you have a lot more end users.
In Docker step, use single container from public Docker Hub, named: yidadaa/chatgpt-next-web
Configure other steps as you like, and finish creating the web app.
Configure Environment Variables
After creating the Web App, we need to configure two environment variables for the Docker container before running the application.
Go to Configuration blade, and add two settings:
- OPENAI_API_KEY: Use your own key bought from Open API official website, usually start with "sk-"
- PORT: 443
I would also suggest turn on HTTP2 in general settings for better performance.
By now, your ChatGPT web UI is ready to run. You can access the page by default domain, or bind your custom domian.
Enable Authentication
By default, your website is publicly accessible from anywhere on the Internet. This can blow up your credit card. We need to enable authentication that asks users to login before using the application.
Although the original ChatGPT Next Web project did not have such features, it is extremely easy to add login providers on Azure without writing any code.
Go to Authentication blade, click "Add identity provider"
You can add any of the listed providers. I am using Microsoft for example.
For Microsoft provider, by default, all accounts in the given Azure AD will have access. To limit accounts to only selected people, see my previous blog post How to Allow Only Selected Users to Access an Application in Azure AD
After completing this step. Users will be asked to login before opening ChatGPT web UI.
Conclusion
Azure App Service is a wonderful PaaS service. It can run Docker based applications and add individual account login flow to the application without modifing code. All steps are just a few mouse clicks that can be finished in a few minutes.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK