网站首页 > 技术教程 正文
前置条件
- 已申请域名包括备案成功
- SSL证书已获得
- Nginx部署方式为源码部署,不会的请参考Linux安装nginx - star-xin - 博客园
- nginx已加载SSL模块,不会的请参考nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37 - ノGHJ - 博客园
nginx.conf正文(直接复制粘贴)
改成自己域名、要转发的http地址
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 5000m;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Tomcat
upstream appServer {
server 127.0.0.1:8080 weight=4;
}
server {
listen 80;
# listen somename:8080;
server_name 域名 ;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl; # https 443
charset utf-8;
server_name 域名; # host_name of URL
# https
#ssl on;
ssl_certificate 证书地址.pem;
ssl_certificate_key 证书地址.key;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# https Tomcat Tomcat http
proxy_set_header X-Forwarded-Proto $scheme;
# Tomcat
proxy_pass 自己的http请求;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
猜你喜欢
- 2024-10-09 面试题 HTTP及web服务相关(nginx apache)
- 2024-10-09 Nginx实现认证登录(nginx登录验证)
- 2024-10-09 Nginx 是如何处理 HTTP 头部的?(女飞行员余旭遗体头部图)
- 2024-09-08 nginx 安装教程(详解)(nginx安装与配置详解)
- 2024-09-08 学习Nginx,跟着阿里大牛走,一套精心整理的Nginx(PDF文档)
- 2024-09-08 nginx实现内外网访问限制(nginx 内网)
- 2024-09-08 nginx的多域http、https同时访问配置及http重定向https
- 2024-09-08 nginx httpstatus 408 研究(404 not found nginx是什么意思)
- 2024-09-08 Nginx完全指南--内容解析(三)(nginx 详解)
- 2024-09-08 Nginx http 强转https(http://cas.tjgl.teacheredu.cn)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)