nginx - 为 statis vuejs 站点配置 nginx
问题描述
我一直在尝试配置我的 nginx vuejs 静态前端。我的网站始终返回 500。我的/etc/nginx/nginx.conf
文件基于此网站。
当我到指定的ip_address时,返回500屏幕并返回特定500 Internal Server Error nginx/1.12.2
的。
为什么会这样做?我知道根文件路径是正确的,但显然找不到它。
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name floating_ip_address;
root ~/frontendFolder;
index index.html
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
编辑:
最新日志如下:
ip - - [12/Sep/2018:16:39:59 +0000] "GET /phpmyadmin-old/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:00 +0000] "GET /phpMyAdminold/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:00 +0000] "GET /phpMyAdmin.old/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:03 +0000] "GET /pma-old/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:03 +0000] "GET /claroline/phpMyAdmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:05 +0000] "GET /typo3/phpmyadmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:07 +0000] "GET /phpma/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:07 +0000] "GET /phpmyadmin/phpmyadmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:15 +0000] "GET /phpMyAdmin/phpMyAdmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:44:37 +0000] "GET / HTTP/1.1" 200 3700 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7" "-"
ip - - [12/Sep/2018:16:47:28 +0000] "GET / HTTP/1.1" 500 595 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36" "-"
解决方案
我不是 nginx 专家,但我们有一个运行 nginx 的生产服务器来为静态 Vue 网站和代理 API 和 WebSocket 请求提供到运行在端口 8200 上的蝴蝶服务器 .NET。
无论如何,这是我们的 nginx 配置文件,希望对您有所帮助...
server {
listen 80;
listen [::]:80;
server_name my.mysite.com;
root /opt/mysite/my;
return 301 https://my.mysite.com$request_uri;
}
server {
listen 443 default_server ssl;
server_name my.mysite.com;
ssl_certificate /opt/mysite/ssl/my_mysite_io.bundle.crt;
ssl_certificate_key /opt/mysite/ssl/my_mysite_io.key;
root /opt/mysite/my;
client_max_body_size 128000000;
# index
index index.html;
# $uri, index.html
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(?:jpg|jpeg|png|ico)$ {
expires 1y;
add_header Cache-Control "public";
access_log off;
}
location /index.html {
expires -1;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
location /api {
proxy_pass http://127.0.0.1:8200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location /ws {
proxy_pass http://127.0.0.1:8200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}
推荐阅读
- mysql - 具有多个引用表的 MYSQL 查询
- json - 如何在 SQL Server 中修改 XML 属性中的 JSON 数据,如果 XML 具有包含 JSON 的属性,例如具有特殊字符的数据
- java - SpringBoot多租户架构中的同步表
- flutter - Flutter Gridview 中的内容居中
- python - 求解器的逻辑回归中的问题
- reactjs - React native - 如何用文本包装视图?
- spring - 多个 Spring Cloud 网关。这可以配置为集群吗?
- python - 如何在 python shell 中创建加载
- javascript - 如何使用箭头键或 WASD 使对象(图像)在画布上平滑移动?
- three.js - Three.js OBJLoader 解析方法不起作用