MAC nginx默認(rèn)路徑
配置文件路徑:
/usr/local/etc/nginx/nginx.conf
錯(cuò)誤日志路徑:
/usr/local/var/log/nginx/error.log
1、nginx訪問配置
server {
listen 3066;
server_name _;
root ; #路徑
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
index index.html index.htm;
try_files $uri $uri/ /index.html;
# try_files $uri $uri/ =404;
}
}
2、代理本地3000端口到3066端口
server {
listen 3066;
server_name _;
index index.html index.htm index.php default.html default.htm default.php;
location / {
proxy_set_header host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:3000/;
}
}
3、代理網(wǎng)絡(luò)端口和本地端口到3066解決跨域問題
server {
listen 3061;
server_name _;
index index.html index.htm index.php default.html default.htm default.php;
location /api/ {
proxy_set_header host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
#網(wǎng)絡(luò)端口
proxy_pass http://8.131.75.244:8801/;
}
location / {
proxy_set_header host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
#本地3000端口
proxy_pass http://127.0.0.1:3000/;
}
}
4、nginx域名配置
server {
listen 443 ssl;
server_name xxx.com;
ssl_certificate crt路徑;
ssl_certificate_key key路徑;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
root 路徑;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#root /code/app1/build;
index index.html index.htm;
try_files $uri $uri/ /index.html;
# try_files $uri $uri/ =404;
}
#反向代理api解決跨域問題
location /api/ {
proxy_set_header host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
#api端口
proxy_pass http://127.0.0.1:8801;
}
}
最后編輯于 :2021.03.11 11:18:49
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者 【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。 平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。