簡單配置Nginx 指向本地端口,並開啓SSL,
若是要開啓SSL,必須使用域名去申請SSL key,通常是兩個文件,通常是要收費的。nginx
# 在/etc/nginx/nginx.conf 的文件中有下面一句,意思是調用 /etc/nginx/conf.d/
# 下面的配置文件,加載到主配置文件(nginx.conf)中。
include /etc/nginx/conf.d/*.conf;網站
# 到/etc/nginx/conf.d 目錄中,建立一個 default.conf文件,加入以下代碼代理
# 配置本地端口
server {
listen 80 default_server;
server_name _;server
location / {
# 增長代理指向本地端口
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}ssl
# 開啓SSL
server {
listen 443 ssl;rem
# 指定SSL 可訪問的網站
server_name cni.emcoo.com www.cni.emcoo.com;
ssl_certificate /etc/nginx/ssl/ssl.crt;
ssl_certificate_key /etc/nginx/ssl/ssl.key;域名
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;io
# 指定 SSL 指向本地端口
proxy_pass http://localhost:3000/;
proxy_redirect off;proxy_pass
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}配置