共计 2206 个字符,预计需要花费 6 分钟才能阅读完成。
nginx 配置
1. 开发环境 vue+node
2. 电脑系统 windows10 专业版
3. 在应用我的项目开发的过程中, 咱们常常会应用 nginx 进行转发, 上面我我的总结, 心愿对你有所帮忙!
4.nginx 官网下载地址:
http://nginx.org/en/download.html
// 本次应用的版本是:1.18.0
5. 下载之后, 咱们会失去这样的一个目录构造:
5-1. 咱们次要配置的是, 如下图:
5-2.conf 文件夹上面的 nginx.conf 代码如下:
#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 8010;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root G:/chendistmo/dist;
index index.html index.htm;
# proxy_pass http://192.168.137.63:3000;
}
location /api {proxy_pass http://192.168.137.63:3000;}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {root html;}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
5-3. 咱们须要批改的中央, 如下图:
5-4. 应用终端进行到 nginx 目录, 如下图:
5-5. 批改实现之后, 咱们用终端进行启动 nginx, 命令如下:
1.start nginx.exe // 启动 nginx
2.nginx -t // 查看是否批改胜利
3.nginx -s reload // 批改实现之后, 重启启动
6. 在浏览器输出 localhost:8010, 效果图如下:
6-1. 数据申请也没有问题, 效果图如下:
7. 本期的分享到了这里就完结啦, 是不是很 nice, 心愿对你有所帮忙, 让咱们一起致力走向巅峰!
正文完