在我的Ubuntu 18.04中,我安装并配置了Nginx。我正在从内部服务器提供小型测试Web api,并使用Nginx作为代理。我使用/etc/nginx/conf.d/default.conf设置并配置我的Nginx。它可以完美地用作代理。仅当用户尝试输入为Http或我不断收到404错误时。我创建了一个小的html5页面,并将其放到根目录/ var / www / html / data /中。现在我收到502床网关错误。
我的问题是我是否使用conf.d / default.conf并配置代理,以便可以在Nginx中放置单个html页面? (在哪里可以将自定义index.html放在Nginx中?)
server {
charset UTF-8;
listen 80;
listen [::]:80;
error_log /var/log/nginx/niyazi.com.error.log debug;
rewrite_log on;
server_name mod.niyazi.com;
include snippets/letsencrypt.conf;
root /var/www/html/data/;
return 301 https://mod.niyazi.com$request_uri;
}
server {
charset UTF-8;
listen 443 ssl http2;
server_name mod.niyazi.com;
ssl_certificate /etc/letsencrypt/live/mod.niyazi.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mod.niyazi.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mod.niyazi.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
location / {
proxy_pass http://192.168.12.120:8280/;
}
if ($request_method !~ ^(GET|HEAD|POST)$ )
{
return 405;
}
}