Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

证书安装完后网站显示index,ip地址显示welcome to nginx #7

Open
DANVEZ opened this issue Dec 11, 2018 · 1 comment
Open

Comments

@DANVEZ
Copy link

DANVEZ commented Dec 11, 2018

大佬,想问个问题。我安装完sspanel,安装大佬的一键脚本,成功拿到证书,结果网站打开是index页面
image
如上图,ip地址打开发现是nginx的欢迎页面。我想显示自己的网站地址,在网路上搜索很久,没有什么好办法,大佬能回复一下吗啊?感谢!
我是在Digital Ocean上安装的Debian8系统。
/etc/nginx/sites-enabled/default,我编辑的是这个文件

root@debian-s-1vcpu-1gb-nyc3-01:/etc/nginx/sites-enabled# vim default
server {
listen 80 138.197.15.188;
listen [::]:80 2604:a880:800:a1::c3f:4001;
return 301 $scheme://xzwk.gq$request_uri;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules;
    }
@Mit2g
Copy link

Mit2g commented Feb 11, 2020

在你的配置文件后添加

server {
	listen 127.0.0.1:80;

	server_name 你的IP;

	return 301 https://你的域名$request_uri;
}

即可实现ip自动跳转域名

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants