Nginx阻止访问我的应用程序使用的端口

时间:2016-10-18 07:18:46

标签: nginx

我需要创建一个重定向表单xxx.xxx.xxx.xxx:8000(myIP:8000)到example.com

我还需要从www.example.com重定向到example.com

我目前的设置有一个制作应用和开发应用:

PROD:

server {
    listen 80;

    server_name xxx.xxx.xxx.xxx;
    return 301 $scheme://example.com$request_uri;
}

server {
    listen 80;

    server_name example.com www.example.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

分段的/ dev:

server {
    listen 80;

    server_name dev.example.com;

    location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;

            # Password protect dev. subdomain
            auth_basic "Restricted Content";
            auth_basic_user_file /etc/nginx/.htpasswd;

    }
}

Nginx对我来说是一个非常新鲜的东西,我很遗憾。

0 个答案:

没有答案