Setup SSL/ HTTPS on NGINX on CentOS 8/ AlmaLinux 8/ RockyLinux 8

Installing SSL can usually be a very tedious process. Luckily for us, Certbot has an automated script to easily help us to get SSL/ HTTPS set up with a few command lines.

To start, install Certbot

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install certbot python3-certbot-nginx

Once Certbot is installed, automatically generate an SSL certificate by running this command. You will be prompted with several inputs to fill in.

certbot --nginx

[root@nginx ~]# certbot --nginx
[root@nginx ~]# certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): test@test.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Account registered.
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel): yourdomain.com
Requesting a certificate for yourdomain.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/yourdomain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/yourdomain.com/privkey.pem
This certificate expires on 2022-04-02.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for yourdomain.com to /etc/nginx/conf.d/nginx.conf
Congratulations! You have successfully enabled HTTPS on yourdomain.evoxt.com
We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[root@nginx ~]#


 

With these set up, your domain's SSL setup should be complete.
 

Note: Your browser might still cache the old self-signed certificate, or the certificate will not update, hence still showing insecure SSL. To fix this, try clearing your browser's cache or try accessing your website with a different browser.
 

To check SSL status, try using this SSL Checker from Geocerts.

<think>好的,用户想设置产品服务器,但可能对具体步骤不太清楚。首先需要明确“产品服务器”具体指什么,是Web服务器、数据库服务器还是应用服务器?根据用户提供的引用内容,可能涉及数据库复制、服务器软件安装和配置,以及安全设置。 引用[1]提到在从服务器上设置唯一的服务器ID,可能需要重启,这可能与数据库服务器如MySQL的主从复制有关。用户可能需要配置主从复制,需要注意server_id的设定和重启步骤。 引用[2]提到下载Datazen服务器软件并关闭IE增强安全性,这可能是在Windows服务器上安装特定软件,需要指导用户下载软件、调整安全设置,可能涉及Server Manager的操作。 引用[3]关于用Dialogflow和React.js构建聊天机器人,虽然不直接相关,但可能用户有后续部署应用的需求,需要配置Web服务器如Nginx或Apache来托管前端应用,或者设置Node.js环境。 接下来需要综合这些信息,分步骤指导用户:首先确定服务器类型,然后安装必要软件,配置网络和安全设置,设置服务器标识(如数据库中的server_id),最后测试部署。同时要提醒用户注意安全措施,如防火墙配置和定期备份。 可能用户遗漏的步骤包括服务器初始化设置、安全组或防火墙规则的调整、依赖软件的安装(如.NET Framework for Datazen)。需要详细说明每个步骤的具体操作,并引用相关参考资料中的步骤,如关闭IE增强安全性和配置服务器ID。 最后,生成的相关问题应涵盖服务器安全、性能优化、部署工具选择以及监控维护,帮助用户全面了解服务器设置的各个方面。</think>设置产品服务器需要根据具体需求选择服务器类型(如Web服务器、数据库服务器等),以下以通用型产品服务器部署为例说明关键步骤: ### 一、基础环境搭建 1. **操作系统配置** 安装CentOS/Ubuntu Server等稳定版本,更新系统补丁: ```bash sudo apt update && sudo apt upgrade -y # Ubuntu sudo yum update -y # CentOS ``` 2. **网络安全设置** 配置防火墙规则,开放必要端口(如HTTP 80/HTTPS 443): ```bash sudo ufw allow 22/tcp # SSH sudo ufw allow 80/tcp sudo ufw enable ``` ### 二、服务部署(以Web服务器为例) 1. **安装Nginx** ```bash sudo apt install nginx -y # Ubuntu sudo systemctl start nginx ``` 2. **配置域名解析** 在`/etc/nginx/sites-available/`创建配置文件,设置server_name和root目录: ```nginx server { listen 80; server_name example.com; root /var/www/html; index index.html; } ``` ### 三、数据库配置(MySQL示例) 1. **安装数据库** ```bash sudo apt install mysql-server -y sudo mysql_secure_installation ``` 2. **主从复制设置** 在my.cnf中添加唯一server_id(主从服务器需不同)[^1]: ```ini [mysqld] server-id = 1 log_bin = /var/log/mysql/mysql-bin.log ``` ### 四、安全加固 1. **禁用root远程登录** 修改SSH配置文件: ```bash sudo nano /etc/ssh/sshd_config # 修改 PermitRootLogin no ``` 2. **安装SSL证书** 使用Let's Encrypt获取免费证书: ```bash sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d example.com ``` ### 五、软件部署注意事项 • Windows服务器需关闭IE增强安全性才能下载特定软件[^2] • 应用部署前需确认运行环境(如.NET Framework版本) • 重要数据建议配置自动备份任务
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值