windows - Windows 的 Nginx 配置设置
问题描述
我正在尝试通过 Windows 上的 nginx 运行我的 vue 应用程序,并且我正在使用以下教程,一个是使用 AlwaysUp 运行 nginx,另一个是配置它。
https://www.coretechnologies.com/products/AlwaysUp/Apps/RunNginxAsAService.html https://graspingtech.com/nginx-virtual-hosts-ubuntu-16-04/
我还偶然发现了以下堆栈溢出问题,这基本上是我遇到的问题,但它没有用:
该服务正在运行并识别我尝试设置的两个域,但无论出于何种原因,它总是将我发送回 NGINX 欢迎页面,我不确定我做错了什么。
我按照第二个教程的步骤进行了一些更改,例如添加“server_names_hash_bucket_size 64;” 到我的 nginx.config 文件。我还使用 windows mklink 在“站点可用”和“启用站点的目录”之间创建了符号链接。
这是我的文件。
Nginx.config
worker_processes 1;
events {
worker_connections 1024;
}
http {
server_names_hash_bucket_size 64;
include mime.types;
default_type application/octet-stream;
include "C:/nginx/nginx/sites-available/*.conf";
sendfile on;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
我在站点可用的应用程序配置文件中还包含启用站点的符号链接:
server {
listen 80;
listen [::]:80;
server_name myapp.nginx.br;
root "C:/Users/Documents/git-repository/my-app/dist";
index index.html;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
解决方案
我还面临如何终止nginx
进程的问题。我偶然发现了一段时间,直到我想出了以下有效的命令:
taskkill /F /FI "IMAGENAME eq nginx.exe"
推荐阅读
- testing - 如何设置 TestCafe 以在 CLI 中指定的环境中运行?
- gcloud - gcloud dataproc 集群创建:没有名为 jsonschema 的模块
- python - 用于传输照片的python套接字编程
- matlab - 太多 for 循环迭代 - for 循环终止
- java - 如何在数组中获得最小值
- coq - 如何在 Coq Software Foundations 中查找关键字的解释?
- java - 如何将几个参数移动到杰克逊的另一个节点?
- vba - VBA - 从 ASP 页面检索数据
- ffmpeg - 使用复杂过滤器 amerge 的 FFmpeg 无法在 iOS 上播放
- javascript - 如何在状态之间为图像设置动画