powershell
cd /home/admin/
解压文件到opt目录下
powershell
tar -xvzf nginx-1.22.1.tar.gz -C /data/usr/local
cd /data/usr/local/nginx-1.22.1
需要ssl的话用这个
powershell
./configure --prefix=/data/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
./configure --prefix=/data/usr/local/nginx --with-http_ssl_module
./configure --prefix=/data/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
make
make install
Nginx配置证书
进入配置目录
powershell
cd /data/usr/local/nginx/conf/
创建cert目录
powershell
mkdir cert
将证书crt和key复制过来
powershell
cp /home/admin/xxx.crt /data/usr/local/nginx/conf/cert
cp /home/admin/xxx.key /data/usr/local/nginx/conf/cert
修改配置文件
powershell
##another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 80;
# listen somename:8080;
server_name **ip地址**;
# location / {
# root html;
# index index.html index.htm;
# }
return 301 https://$http_host$request_uri;
}
# HTTPS server
#
server {
listen 443 ssl;
server_name **ip地址**;
ssl_certificate /data/usr/local/nginx/conf/cert/xxx.crt;
ssl_certificate_key /data/usr/local/nginx/conf/cert/xxx.key;
ssl_session_cache shared:SSL:1m;
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 /data/vue;
index index.html;
try_files $uri $uri/ /index.html;
}
location ^~/api {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://ip地址:8081;
}
}