nginx添加http_ssl_module并且配置域名指定端口的操作方法
1.切換到源碼包:
cd /home/nginx-1.23.1
2.進行編譯:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
3.配置完成后,運行命令:
make
make命令執(zhí)行后,不要進行make install,否則會覆蓋安裝。
4.備份原有已安裝好的nginx:
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
5.停止nginx狀態(tài):
/usr/local/nginx/sbin/nginx -s stop
6.將編譯好的nginx覆蓋掉原有的nginx:
cd /home/nginx-1.23.1/ cp ./objs/nginx /usr/local/nginx/sbin/
7.提示是否覆蓋,輸入yes即可。
8.然后啟動nginx:
/usr/local/nginx/sbin/nginx
9.進入nginx/sbin目錄下,通過命令查看模塊是否已經加入成功:
cd /usr/local/nginx/sbin/ ./nginx -V
10.有以下提示,證明已經編譯成功:
nginx version: nginx/1.23.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
nginx配置域名
server { listen 443 ssl; server_name xxx.cn; ssl_certificate cert/xxx.pem; ssl_certificate_key cert/xxx.key; ssl_session_timeout 5m; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_prefer_server_ciphers on; add_header Content-Security-Policy upgrade-insecure-requests; client_max_body_size 200M; server_tokens off; autoindex on; charset uft8; error_page 500 502 503 504 /50x.html; location / { root /mnt/dist; index index.html index.htm; error_page 405 =200 $request_uri; try_files $uri $uri/ /index.html; } location /api{ proxy_pass http://127.0.0.1:8080; proxy_read_timeout 360; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; client_max_body_size 500m; } location = /50x.html { root /usr/share/nginx/html; } }
附帶linux下防火墻和開放端口
#查看防火墻是否開啟(如果顯示running,則防火墻為開啟狀態(tài)): firewall-cmd --state #關閉防火墻: systemctl stop firewalld.service #開啟防火墻 systemctl start firewalld.service 1、開啟防火墻 systemctl start firewalld ? 2、開放指定端口 firewall-cmd --zone=public --add-port=443/tcp --permanent 命令含義: --zone #作用域 --add-port=1935/tcp #添加端口,格式為:端口/通訊協議 --permanent #永久生效,沒有此參數重啟后失效 ? 3、重啟防火墻 firewall-cmd --reload # 查詢端口是否開放 firewall-cmd --query-port=8080/tcp lsof -i:8080(如果沒有l(wèi)sof,可以使用 yum install lsof 下載) # 開放80端口 firewall-cmd --permanent --add-port=80/tcp # 移除端口 firewall-cmd --permanent --remove-port=8080/tcp #重啟防火墻(修改配置后要重啟防火墻) firewall-cmd --reload
到此這篇關于nginx下添加http_ssl_module并且配置域名,指定端口的文章就介紹到這了,更多相關nginx添加http_ssl_module內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
nginx配置完rewrite瀏覽器提示將您重定向的次數過多的解決方法
本文主要介紹了nginx配置完rewrite瀏覽器提示將您重定向的次數過多的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-07-07使用google-perftools優(yōu)化nginx在高并發(fā)時的性能的教程(完整版)
如果使用googler開發(fā)的google-perftools優(yōu)化Nginx和MySQL的內存管理,性能將會有一定程度的提升。特別是對高并發(fā)下的服務器,效果更明顯2013-02-02