准备好工作目录

mkdir work
cd work
mkdir conf logs

准备好 conf/nginx.conf 配置文件, 把 your.domain 换成你自己的域名

user abcd; ## 换成自己的 user
worker_processes 1;
error_log logs/error.log warn;
events {
worker_connections 1024;
} http {
resolver 114.114.114.114 ipv6=off; lua_package_path '${prefix}lua/?.lua;;';
lua_code_cache on; ssl_certificate /etc/letsencrypt/live/your.domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on; lua_ssl_verify_depth 2;
lua_ssl_trusted_certificate /etc/pki/tls/certs/ca-bundle.crt; sendfile on; server {
listen 8080 ssl;
server_name your.domain;
keepalive_timeout 70; ## http://domain.name:8080 自动跳转到 https://domain.name:8080
error_page 497 301 =307 https://$host:$server_port$request_uri; location ~ ^/api/([-_a-zA-Z0-9/]+) {
access_by_lua_file lua/access_check.lua; content_by_lua_file lua/$1.lua; } location / {
default_type text/html;
content_by_lua_block {
ngx.say("<p>hello, world</p>")
}
}
} server { ## 禁止 ip 直接访问
listen 8080 default_server;
server_name _;
return 500;
}
}

openresty 启动

cd work
openresty -p `pwd` -c conf/nginx.conf

-p 指定工作目录

-c 指定配置文件

reload 配置文件也要带上启动时的 -p -c

openresty -p `pwd` -c conf/nginx.conf -s reload

openresty(nginx) 配置 http与https使用同一个端口,禁止 IP 直接访问的更多相关文章

  1. nginx关闭默认站点/空主机头(禁止IP直接访问、防止域名恶意解析)

    监控时做了负载均衡,所以只能让nginx指定域名访问,那我们就可以防止因为域名不对跳到默认的页面去. curl  -I   -H  “host:域名”   --include   https://19 ...

  2. Windows下Nginx配置SSL实现Https访问(包含证书生成)

    Vincent.李   Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...

  3. Nginx禁止IP直接访问网站

    禁止别人直接通过IP访问网站,在nginx的server配置文件前面加上如下的配置,如果有通过IP直接访问的,直接拒绝连接(需要去掉别的server下的default_server). server ...

  4. 设置nginx禁止IP直接访问,只能通过指定的域名访问

    nginx的版本是1.2.1. 设置配置文件disableip.conf: server {     listen 80;     server_name _;     return500; } 这是 ...

  5. openresty(nginx) 配置 stream 转发

    nginx从1.9.0开始,新增加了一个stream模块,用来实现四层协议的转发.代理或者负载均衡等. (1)关于stream域的模块有哪些? 目前官网上列出的第三方模块.简直就是http模块的镜像. ...

  6. Centos7.2下Nginx配置SSL支持https访问(站点是基于.Net Core2.0开发的WebApi)

    准备工作 1.基于nginx部署好的站点(本文站点是基于.Net Core2.0开发的WebApi,有兴趣的同学可以跳http://www.cnblogs.com/GreedyL/p/7422796. ...

  7. 使用SSL安全证书和nginx配置将域名HTTPS化

    一.在阿里云后台申请免费版证书: 二.在域名解析里面添加记录: 三.提交审核: 四.等待审核通过后,下载nginx证书: 五.按照文档修改nginx配置文件: https://help.aliyun. ...

  8. linux下nginx配置ssl证书(https)

    nginx配置ssl很简单,首先需要两个文件,一个是crt文件,另一个是key文件,如下所示: xxx.crt;  #(证书公钥)xxx.key; #(证书私钥) 把这两个文件放到nginx的conf ...

  9. nginx配置自签名https

    nginx配置https是需要CA颁发证书的,为了测试方便,我们可以使用自签名证书 1.如何生成自签名证书 1.1:我们需要为服务端和客户端准备私钥和公钥: //生成服务器端私钥 openssl ge ...

随机推荐

  1. C++第三十五篇 -- 写第一个驱动开发程序

    VS2017+WDK+VMware12+Win10环境配置完毕,接下来写第一个驱动程序. 1.新建一个KMDF的程序. 2.配置项目属性. 3.编译项目.一般这里应该成功,我一台电脑成功了,另一台电脑 ...

  2. python3实现名片管理系统(文件版)

    def menu(): #首先定义功能列表函数menu() print(" 名片管理系统 V1.0 ") print("1:增加新用户") print(&quo ...

  3. vscode配置及插件

    编辑vue时候的用户配置 { "workbench.colorTheme": "Solarized Dark", // 主题 "editor.dete ...

  4. VSCode远程免密登录

    VSCode远程免密登录 本地生成密钥 生成命令如下: ssh-keygen -t rsa 会生成id_rsa, id_rsa.pub两个文件 公钥拷贝到服务器 将公钥id_rsa.pub拷贝到服务器 ...

  5. 大数据学习(06)——Ozone介绍

    前面几篇文章把Hadoop常用的模块都学习了,剩下一个新模块Ozone,截止到今天最新版本是0.5.0Beta,还没出正式版.好在官方网站有文档,还是中文版的,但是中文版资料没有翻译完整,我试着把它都 ...

  6. S01-晓亮的电脑软件安装过程文档 腾讯QQ 595076941 2019年10月

    S01-晓亮的电脑软件安装过程文档 腾讯QQ 595076941 2019年10月 本文档的创建作者的腾讯QQ聊天号码是 595076941 S02-电脑软件安装过程中不要随意关闭窗口除非必需关闭窗口 ...

  7. mout -t -cifs 解析

    mount -t cifs //<azurefile_url> <linux_mountpoint(folder)> df 查看挂载 umount取消挂载 umount -l ...

  8. docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

    docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon run ...

  9. Python实现猜数字游戏

    Python中实现猜数字游戏代码如下: import random # 引入随机数标准库-random # 定义数字上下限和最大游戏次数 min_num = 1 max_num = 10 guess_ ...

  10. C++水仙花 (如:153 = 1*1*1 + 5*5*5 + 3*3*3)

    1 #include <iostream> 2 #include <ctime> 3 using namespace std; 4 5 int main() 6 { 7 int ...