DarkTime
  • README
  • SpringBoot
    • spring boot 运维
    • Spring Boot 部署war包
    • springboot搭建
    • spring boot 读取配置文件
    • 简单总结
    • spring配置文件
    • spring boot Configuration
    • spring boot 配置文件
    • spring boot 配置mybatis
  • MacAwesome
    • markdown使用
    • MAC APP Awesome
    • [markdown使用](/MacAwesome/SUMMARY.md)
    • chrome
    • intellij idea
    • MacAwesome
    • VS Code 的使用
    • MAC Shell命令
  • database
    • druid使用
  • 框架
    • 项目拆析
    • 各种框架和工具
  • docker
    • kubernetes
    • docker
    • docker 常用镜像
  • 效率工具
    • 解决dns污染导致域名解析失败
    • sonarqube 相关配置
    • Iterm2 使用
    • gitbook
    • github awesome github资源推荐
    • playground 在线试用平台汇总
    • linux中的office
    • linux screen 工具
    • 简单Mock服务(moco)
    • npm
    • Visual Studio Code 的使用
    • 配置开发环境
    • homebrew的使用
    • 汇总
  • tomcat
    • tomcat目录规范
  • code_snippets
  • 专题
    • RESTful API
    • serveless服务
    • 搭建私有云主机 折腾记
    • 开发中的各种疑难杂症问题
    • spring 最佳实践
    • LLM 大语言模型
    • notelive
      • 文章框架
      • notelive vue版本开发
      • notelive 开发 札记
    • webrtc技术分析
    • 反向代理
    • spring-cloud
      • spring boot admin 监控服务
      • Spring Cloud 整理汇总
  • python
    • python 学习
    • Python 修饰器的一些小细节
  • 云主机
    • aliyun 主机的种种
  • maven
    • maven使用
    • maven项目增加编译版本号 buildnumber-maven-plugin
    • 仓库
  • java
    • java 开发常用工具类
    • java
    • apache commons pool 对象连接池
  • 大数据
    • kafka
    • gobblin
    • sqoop 简介及使用
    • hbase
    • gobblin
    • sqoop源码解析
    • hadoop map reduce
    • 大数据 学习札记
  • 脚本
    • python
      • 批量请求url 解析json数据
    • js
      • sheetjs-js读取excel
    • shell
      • 自动生成bitbook的summary文件
      • linux/mac 实用脚本
      • 自动创建tomcat项目脚本
      • 批量处理文件内容脚本
  • nginx
    • nginx
    • ngix 文件浏览器 文件服务器
  • linux
    • 群晖nas札记
    • ftp
    • linux 运维
    • 常用命令
    • linux
    • mysqldump脚本
    • 代理
    • 简易灰度部署脚本 不使用jenkins的纯shell方式
    • shell脚本
    • 附加文档
  • mysql
    • sql
  • 游戏开发
    • Unity 2020 学习笔记
  • 学习笔记
    • centos常用环境安装
    • gradle 学习
    • 建站经历
    • python
      • 爬虫教程
    • 如何解决百度爬虫无法爬取搭建在Github上的个人博客的问题? - 知乎
    • baas
      • 在本地部署Parse Server
    • mysql学习标记
    • java code snippets
    • 非Spring Boot Web项目 注册节点到Eureka Server并提供服务
    • kotlin
      • Kotlin 学习札记
    • spring cloud
    • vim配置
    • 前端
      • 开发PWA应用
  • jenkins
    • jenkins配置备份
    • gitlab触发Jenkins 自动构建
    • 安装与使用
  • npm
    • npm 使用
  • git
    • ignore
    • git使用总结
    • git配置多个远程仓库
  • 前端
    • swig
    • 解决跨域请求问题
    • angularjs 学习
    • scriptbot的前端开发经验总结
    • 各种资源
    • 一些有用的js代码
Powered by GitBook
On this page
  • nginx
  • nginx 做域名绑定
  • nginx 配置ssl https请求
  • nginx 配置301跳转
  • 使用nginx stream
  • 要注意不要放到http块中,因为这个不是http转发而是tcp层的转发
  • stream模块使用yum安装的高版本nginx是有的,编译安装的默认可能没有

Was this helpful?

  1. nginx

nginx

PreviousnginxNextngix 文件浏览器 文件服务器

Last updated 6 years ago

Was this helpful?

nginx

nginx 做域名绑定

nginx 配置ssl https请求

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name *.rizon.top;
    ssl on;
    root html;
    index index.html index.htm;
    ssl_certificate   /etc/nginx/cert/certificate.pem;
    ssl_certificate_key  /etc/nginx/cert/certificate.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    location / {
        root /home/website;
        index index.html index.htm;
    }
}

nginx 配置301跳转

## nginx 反向代理

[nginx配置url重定向-反向代理-大風-51CTO博客](http://blog.51cto.com/lansgg/1575274)  

/etc/nginx/nginx.conf

```conf /etc/nginx/nginx.conf
server {
listen    80 default_server;
server_name    www.lansgg.com lansgg.com;
access_log    logs/lansgg.access.log main;
error_log    logs/lansgg.error.log;
root        /opt/nginx/nginx/html/lansgg;
location / {
    index index.html;
    }
location /other {
proxy_pass          http://192.168.10.129/other;
proxy_set_header    X-Real-IP $remote_addr;
    }
}

使用nginx stream

tag 代理mysql stream代理ssh tcp反向代理 nginx代理ssh

/etc/nginx/nginx.conf

```conf /etc/nginx/nginx.conf

要注意不要放到http块中,因为这个不是http转发而是tcp层的转发

stream模块使用yum安装的高版本nginx是有的,编译安装的默认可能没有

stream {

#配置upstream是用与负载均衡的,可以不这样配置
upstream cloudsocket {
   hash $remote_addr consistent;
  # $binary_remote_addr;
   server 192.168.182.155:3306 weight=5 max_fails=3 fail_timeout=30s;
}
#代理mysql
server {
   listen 3306;#数据库服务器监听端口
   proxy_connect_timeout 10s;
   proxy_timeout 5m; #这个属性的含义不太清楚,和mysql的连接时间应该似乎有关系,时间太短似乎会导致mysql的连接被中断
   #负载均衡配置方法
   #proxy_pass cloudsocket;
   # 简单配置方法
   proxy_pass 10.69.65.96:3306;
}

#代理ssh
server {
        listen 80;
        proxy_pass ssh;
        proxy_connect_timeout 1h;
        proxy_timeout 1h;
}

}

## nginx 重定向 rewrite

[http重定向301/302/303/307](https://blog.csdn.net/reliveit/article/details/50776984)
[Nginx URL重写(rewrite)配置及信息详解](https://www.cnblogs.com/czlun/articles/7010604.html)

```conf /etc/nginx/nginx.conf
server {
        listen 80;
        server_name abc.com;
        #显式url跳转 永久重定向
        #rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
        # 显式url跳转,临时重定向
        rewrite ^/(.*)$ https://rizon.top/tool/ last;
}

语法说明 rewrite regex replacement [flag]; 关键字 正则 替代内容 flag标记

正则:perl兼容正则表达式语句进行规则匹配 替代内容:将正则匹配的内容替换成replacement flag标记:rewrite支持的flag标记

flag标记说明: last #本条规则匹配完成后,继续向下匹配新的location URI规则 break #本条规则匹配完成即终止,不再匹配后面的任何规则 redirect #返回302临时重定向,浏览器地址会显示跳转后的URL地址 permanent #返回301永久重定向,浏览器地址栏会显示跳转后的URL地址

```conf /etc/nginx/nginx.conf server_name example.com; return 301 ;

nginx server_name
nginx学习(十)——nginx的配置系统6之server_name - CSDN博客
Nginx中的默认主机及location设置(摘自淘宝) - CSDN博客
Nginx启动SSL功能,并进行功能优化,你看这个就足够了
FreeSSL - 一个申请免费HTTPS证书的网站
Nginx+Https配置 - 倚楼听风雨 - SegmentFault 思否
官方-配置HTTPS服务器
Nginx环境强制http 301跳转https设置记录
https://$host$request_uri
Module ngx_stream_core_module
caojx-git/learn nginx使用stream模块做ssh转发