• 配置nginx域名转发


    这应该是,我在这个网站的最后一篇博客了。
    国庆的时候不知道为什么突然买了个服务器,我打算自己建一个博客网站了,然后前两天域名刚备案成功,晚上有空就配置服务器。

    服务器先安装jdk,jre基础环境,然后nginx,redis这些。我之前的博客都有写过。mysql装的是8.0的版本,比5.7版本快两倍(官方解释说)。然后8.0的版本mybatis上能用cte,5.7的版本太古老了。

    关于域名的服务器配置nginx。

    我在腾讯买的域名,然后备案后,在SSL证书下载nginx的文件。

    https://cloud.tencent.com/document/product/400/4143
    
    • 1

    这是腾讯关于配置SSL证书nginx域名。

    可以免费申请SSL证书,然后下载证书文件。用到crt和key文件。

    安装nginx后,配置nginx:

    #user  nobody;
    #==工作进程数,一般设置为cpu核心数
    worker_processes  2;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
    	#==最大连接数,一般设置为cpu*2048
        worker_connections  1024;
    }
    
    http {
    
    	server_names_hash_bucket_size 64;
        include       mime.types;
        default_type  application/octet-stream;
    
        
    	access_log off;
        
    	sendfile        on;
    
       
        server {
    	listen 443 ssl;#监听443端口(https默认端口)
    	
    	server_name www.zouxiongnb.com zouxiongnb.com; #填写绑定证书的域名
    	
    	ssl_certificate zouxiongnb.com.crt;#填写你的证书所在的位置
    	
    	ssl_certificate_key zouxiongnb.com.key;#私钥文件名称
    	
    	ssl_session_timeout 5m;
    	
    	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
    	
    	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置,配置加密套件,写法遵循 openssl 标准。
    	
    	ssl_prefer_server_ciphers on;
    
    	if ($host = zouxiongnb.com ) {
    		return 301 https://www.$host$request_uri;
    	}	
    	
    	location / {
    		root   html;
    		index index.html index.htm;
    		proxy_pass http://124.220.82.248:8080;
    	}
    	
        }
    
    
    
    
    
    	# 各个域名单独控制
        #include vhost/zouxiongnb.conf;
    	
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65

    然后启动nginx,这边访问的时候需要域名加端口,到tomcat服务器conf下的server.xml改port 8080 为80,就不用加端口号也能访问了。
    参考链接:

    https://blog.csdn.net/qq_43251098/article/details/105361671?ops_request_misc=&request_id=&biz_id=102&utm_term=%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E5%9F%9F%E5%90%8D%E5%8F%96%E6%B6%88%E8%AE%BF%E9%97%AE%E5%B8%A6%E7%AB%AF%E5%8F%A3%E5%8F%B7&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-4-105361671.142^v62^opensearch_v2,201^v3^add_ask,213^v1^t3_control2&spm=1018.2226.3001.4187
    
    • 1

    你用ip访问8080端口还是可以访问的。

    腾讯的配置SSL证书nginx服务器地址。

    https://cloud.tencent.com/document/product/400/35244
    
    • 1

    关于nginx文件配置的正确与否验证:
    在nginx根目录下,使用nginx -t
    在这里插入图片描述

    文件编辑需要使用utf-8格式,下载editplus或者notepad编辑,保存为utf-8格式,使用utf-8bom格式会报错。

  • 相关阅读:
    孙卫琴的《精通Vue.js》读书笔记-插槽slot的基本用法
    嵌入式linux总线设备驱动模型分析
    1990-2021年全国30省城镇登记失业率
    git cherry-pick详解
    图像生成2
    [CSS入门到进阶] 你真的了解 width height 吗?
    Ansible的lookup,query,with_xxx
    数据结构--》解锁数据结构中树与二叉树的奥秘(一)
    【操作系统笔记十二】Linux常用基础命令
    微信小程序隐藏video标签的进度条组件
  • 原文地址:https://blog.csdn.net/userzou/article/details/127581498