Nginx反向代理,HTTPS无法正常工作

时间:2017-08-08 10:11:06

标签: amazon-web-services ssl nginx https reverse-proxy

我已成功获得SSL证书,现在我尝试使用NGINX预留代理设置将其实施到我的AWS服务器中,这是配置文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <!-- tools:showIn="@layout/navigation_activity_main"-->


    <RelativeLayout
        android:id="@+id/search_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:padding="@dimen/activity_horizontal_margin">

        <android.support.v7.widget.SearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:queryHint="Search Services" />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/middle_item"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/search_layout"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/search_layout"
            android:padding="@dimen/activity_horizontal_margin"
            android:text="Recommended Services"
            android:textSize="15dp" />

        <ViewFlipper
            android:id="@+id/flipper1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:flipInterval="3000"
            android:inAnimation="@android:anim/slide_in_left"
            android:outAnimation="@android:anim/slide_out_right">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="110dp"
                android:layout_gravity="center_horizontal"
                android:contentDescription="ImageOne"
                android:src="@mipmap/ic_launcher" />
        </ViewFlipper>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/middle_item"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <GridView
                android:id="@+id/gridview"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:columnWidth="90dp"
                android:gravity="center"
                android:horizontalSpacing="1dp"
                android:numColumns="3"
                android:stretchMode="columnWidth"
                android:verticalSpacing="1dp">

            </GridView>
            <Button
                android:id="@+id/btnallservice"
                style="@style/Widget.AppCompat.Button.Colored"
                android:layout_width="match_parent"
                android:layout_height="45dp"
                android:layout_gravity="center"
                android:background="@drawable/ic_action_name"
                android:ems="10"
                android:gravity="center"
                android:text="All Services"
                android:textSize="20dp"
                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

如果我更改设置以收听端口80,那么它可以正常工作。我在AWS安全组中启用了端口443,这是server { listen 80; server_name example.com; return 301 https://www.example.com$request_uri; } server { listen 443 ssl; ssl_certificate /etc/nginx/ssl/cert_chain.crt; ssl_certificate_key /etc/nginx/ssl/website.key; server_name ~^(?<subdomain>.+)\.example\.com$; location / { proxy_pass http://www.example.com:8888; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $subdomain.example.com; proxy_cache_bypass $http_upgrade; } }

的结果
netstat -tulpn | grep 443

所以这意味着它已经正确地听443端口了吗?我还确保使用(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -

以root身份运行nginx
ps aux|grep nginx|grep -v grep

我检查了Nginx错误日志,但内部没有任何内容,但是当我使用https访问我的网址时,它只显示响应时间太长。有人能帮忙吗?谢谢。

更新

以下是root 11567 0.0 0.3 177080 3060 ? Ss 09:36 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; www-data 11568 0.0 0.7 177344 7568 ? S 09:36 0:00 nginx: worker process 的结果:

lsof -i:443

0 个答案:

没有答案