目录
1.nginx官网下载地址
选择“download”
在下载界面选择自己想要下载的版本,点击对应版本,下载Nginx。
2.nginx的使用
(1)解压nginx压缩包。
(2)在nginx的配置文件是conf目录下的nginx.conf,默认配置的nginx监听的端口为8080,如果本地80端口已经被使用则修改成其他端口。这里我使用的端口是8012
注意:nginx.conf文件的编码格式不能保存为UTF-8格式的,需要保存为:ANSI
3.启动nginx
双击nginx.exe即可启动nginx
4.访问nginx
访问nginx:ip+端口
5.nginx自启动
(1)下载最新版的 Windows Service Wrapper 程序下载地址:Releases · winsw/winsw · GitHub
(2)将重命名后的 winsw.exe 复制到 nginx 的安装目录(我这里是"E:\1tool\3nginx-1.22.0")
(3)在同一个nginx目录下创建一个Windows Service Wrapper的XML配置文件winsw.xml,名称必须和winsw.exe的名称一致。
winsw.xml的文件内容如下:
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>E:\1tool\3nginx-1.22.0\nginx.exe</executable>
<logpath>E:\1tool\3nginx-1.22.0\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-p</startargument>
<startargument>E:\1tool\3nginx-1.22.0\</startargument>
<stopexecutable>E:\1tool\3nginx-1.22.0\nginx.exe</stopexecutable>
<stopargument>-p</stopargument>
<stopargument>E:\1tool\3nginx-1.22.0\</stopargument>
<stopargument>-s</stopargument>
<stopargument>stop</stopargument>
</service>
(4)已管理员身份运行cmd,执行命令:
E:\1tool\3nginx-1.22.0\winsw.exe install
(5)查看服务,ngixn自启动设置成功
在服务中查询是否有nginx服务
6.nginx配置https
(1)nginx.conf配置文件中的端口后面加上 ssl
(2)nginx.conf配置文件中配置域名
(3)将hhtps证书拷贝到nginx.conf配置文件同一目录下,并在nginx.conf中配置证书名称
(4)nginx.conf中配置证书
(5)完整配置
7.nginx禁用3DES和DES算法
在nginx/conf/nginx.conf文件中添加如下:
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#只允许TLS协议
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
#加密套件,这里用了CloudFlares Internet facing SSL cipher configuration
ssl_prefer_server_ciphers on;
#由服务器协商最佳的加密算法
ssl_prefer_server_ciphers on;
#由服务器协商最佳的加密算法
8.nginx.conf文件(不含https配置)
#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;
server {
listen 8012;
server_name localhost;
client_max_body_size 300m; #主要是这个参数,限制了上传文件大大小
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#只允许TLS协议
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
#加密套件,这里用了CloudFlares Internet facing SSL cipher configuration
ssl_prefer_server_ciphers on;
#由服务器协商最佳的加密算法
location /ak_hkyg_yxfx {
proxy_pass http://localhost:8080;
}
location /sys-api {
proxy_pass http://localhost:9999;
}
location /manage-api {
proxy_pass http://localhost:9999;
}
location /examination-api {
proxy_pass http://localhost:9999;
}
location /hangjingsoft {
proxy_pass http://localhost:8080;
}
location / {
root html;
index index.html index.htm;
}
}
}
9.nginx.conf文件(包含https配置)
#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;
server {
listen 8012 ssl;
server_name www.xinjintu.com;
client_max_body_size 300m; #主要是这个参数,限制了上传文件大大小
ssl_certificate 3333_www.aaa.com.pem;
ssl_certificate_key 3333_www.aaa.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#只允许TLS协议
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
#加密套件,这里用了CloudFlares Internet facing SSL cipher configuration
ssl_prefer_server_ciphers on;
#由服务器协商最佳的加密算法
location /ak_app_xlq {
proxy_pass http://www.aaa.com:8080;
}
location /sys-api {
proxy_pass http://www.aaa.com:9999;
}
location /manage-api {
proxy_pass http://www.aaa.com:9999;
}
location /mapobj-api {
proxy_pass http://www.aaa.com:9999;
}
location /hjxz {
proxy_pass http://www.aaa.com:8080;
}
location /ak_app_bhxmgc {
proxy_pass http://192.168.100.11:8080;
}
location /sys-api-xmdc {
proxy_pass http://192.168.100.11:9999;
}
location /manage-api-xmdc {
proxy_pass http://192.168.100.11:9999;
}
location /mapobj-api-xmdc {
proxy_pass http://192.168.100.11:9999;
}
location /hjxzxmdc {
proxy_pass http://192.168.100.11:8080;
}
location /ak_bh_xmgc {
root html;
proxy_pass http://39.96.44.78:8080;
}
location /ak_app33 {
root html;
proxy_pass http://39.96.44.78:8080;
}
}
// 如果有其他项目 单独的前端 可以单独 设置路径
location /output {
alias output;
index index.html index.htm;
}
}