nginx配置http服务
- server {
- listen 80; # 监听的端口号
- server_name xxxxxxx; # 服务器的ip或者域名
-
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- # 前端服务反向代理配置
- location / {
- proxy_http_version 1.1;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- root /root/baker/vue-recruit/dist; # dist目录在服务器的完整路径
- index index.html index.htm;
- }
-
- # 后端服务反向代理配置
- location /api {
- proxy_http_version 1.1;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_pass http://xxxxxxx:9999/; # 后端服务所部署的服务器地址以及端口号
- }
- }
- server
- {
- listen 443 ssl;
- server_name xxxxxxx;
- ssl_certificate certxxxx.pem;
- ssl_certificate_key cert/xxxxxx.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 / {
- proxy_http_version 1.1;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- root /www/spider/backend-admin/dist; # dist目录在服务器的完整路径
- index index.html index.htm;
- }
-
- location /api {
- proxy_http_version 1.1;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_pass http://127.0.0.1:xxxx; # 后端服务所部署的服务器地址以及端口号
- }
-
- }
ssl证书通过腾讯或者阿里,宝塔申请就行,下载下来配置