Amazon web services Nginx不显示自定义根文件夹';s文件
我在一个nginx EC2实例前面使用了一个经典的负载平衡器,并将我站点的a-record指向了负载平衡器。即使我的根目录指向一个自定义文件夹/home/ubuntu/mydomain/pulic,我也会得到默认的nginx页面 当我更改html文件夹下index.html文件的内容时,我能够看到更改。但是,我不知道这一页是从哪里来的。我尝试在/usr/local/nginx/conf/nginx.conf和/usr/src/nginx-1.13.6/conf/nginx.conf修改根路径。但不起作用(未发现任何变化) 有人能帮我吗?谷歌以不同的方式对此进行了搜索,但没有找到任何帮助 我要寻找的是负载平衡器和EC2实例之间的安全HTTPS连接Amazon web services Nginx不显示自定义根文件夹';s文件,amazon-web-services,nginx,default,Amazon Web Services,Nginx,Default,我在一个nginx EC2实例前面使用了一个经典的负载平衡器,并将我站点的a-record指向了负载平衡器。即使我的根目录指向一个自定义文件夹/home/ubuntu/mydomain/pulic,我也会得到默认的nginx页面 当我更改html文件夹下index.html文件的内容时,我能够看到更改。但是,我不知道这一页是从哪里来的。我尝试在/usr/local/nginx/conf/nginx.conf和/usr/src/nginx-1.13.6/conf/nginx.conf修改根路径。但
注意:我手动安装了nginx,没有使用apt-get。如果运行命令
nginx-t
,它应该输出正在使用的配置文件的位置:
root@myhost:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
如果查看该文件,您将找到主http
config-服务器的全局配置。您可以在该文件中找到配置的默认站点,也可以由另一个文件中的include语句引用,例如include/etc/nginx/conf.d/*.conf代码>
我建议不要编辑默认站点,而是在nginx.conf的mainhttp
部分中添加一个额外的server
块,或者更好地添加到一个单独的.conf文件中,该文件包含在主配置文件中,如下所示:include/path/to/my/example.com.conf
。这样做意味着通过浏览器访问服务器的IP将不会显示您的网站(您应该将默认文档替换为空白文件)
如果您想托管,您将创建一个配置文件,如/path/to/www.example.com.conf,其中包含:
# main https://www.example.com config
server {
server_name www.example.com;
listen 443 ssl;
#public and private keys for your ssl certificate.
ssl_certificate /path/to/www.example.com/ssl/fullchain.pem;
ssl_certificate_key /path/to/www.example.com/ssl/privkey.pem;
# there are common sense values for SSL
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
server_tokens off;
# you can generate this file from the shell: openssl dhparam -out /etc/nginx/dhparam.pem 2048
#ssl_dhparam /etc/nginx/dhparam.pem;
# if its just ELB you can restrict this to just TLSv1.2
#ssl_protocols TLSv1.1 TLSv1.2;
# The following list should work and only use more modern ciphers, but do your research/trial and error
# on which ciphers your ELB can use and pick the strongest.
##ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
#Adding this header will force browsers to only ever request HTTPS from your site.
##add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
#set your web root here:
root /path/to/www.example.com/httpdocs;
#default document
index index.html;
}
# redirect HTTP www.example.com to HTTPS for cannonical URL
server {
listen 80;
server_name www.example.com;
return 301 https://www.example.com$request_uri;
}
然后在主nginx.conf文件的http
部分中添加以下行:
include /path/to/www.example.com.conf;
再次运行nginx-t
检查更改是否有效,然后在浏览器中进行测试