龙空技术网

nginx配置攻略

骑牛的潇潇 99

前言:

当前同学们对“nginx编译gzip”都比较重视,朋友们都需要剖析一些“nginx编译gzip”的相关内容。那么小编也在网上网罗了一些有关“nginx编译gzip””的相关内容,希望姐妹们能喜欢,大家一起来学习一下吧!

#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;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;  server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root xcrmaster;try_files $uri $uri/ /index.html;index index.html index.htm;}location /prod-api/ {proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass ;}error_page 500 502 503 504 /50x.html;location = /50x.html {root xcrmaster;}}}

主要说明

server{} --配置服务的代码块

server {listen 80;--配置前端服务访问的端口

配置首页的转发路径:

location / {

root xcrmaster;#配置nginx目录下对应的路径;这个路径直接把 npm run build:prod 编译生成的目录dist/*下的所有内容放上去即可

try_files $uri $uri/ /index.html;

index index.html index.htm;

}

配置后端请求路径:

proxy_pass ;

标签: #nginx编译gzip