niginx反向代理背后的Oauth服务器应用程序

时间:2018-12-04 07:09:04

标签: asp.net-mvc oauth nginx-reverse-proxy

我在服务器中使用了OAuth身份验证。我正在尝试使用nginx反向代理和ssl进行服务器配置。 我已使用niginx反向代理配置将https请求重定向到http。

我的Nginx服务器块看起来像:

server {
    listen       193.169.200.88:8084;
    server_name  test2.test.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
         proxy_pass http://localhost:50489/;
         proxy_redirect off;

         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_max_temp_file_size 0;
         client_max_body_size 10m;
         client_body_buffer_size 128k;
         proxy_connect_timeout 90;
         proxy_send_timeout 90;
         proxy_read_timeout 90;
         proxy_buffer_size 4k;
         proxy_buffers 4 32k;
         proxy_busy_buffers_size 64k;
         proxy_temp_file_write_size 64k;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:82
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

server {
    listen       171.16.202.219:443 ssl;
    server_name  test2.test.com;        
    ssl_certificate /nginx/conf/nginxnew.crt;
    ssl_certificate_key /nginx/conf/nginxnew.key;

    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers   on;

    location / {
        proxy_pass http://193.169.200.88:8084;
  proxy_redirect off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_max_temp_file_size 0;
  client_max_body_size 10m;
  client_body_buffer_size 128k;
  proxy_connect_timeout 90;
  proxy_send_timeout 90;
  proxy_read_timeout 90;
  proxy_buffer_size 4k;
  proxy_buffers 4 32k;
  proxy_busy_buffers_size 64k;
  proxy_temp_file_write_size 64k;
    }
}

如果我在本地计算机上运行服务器,则可以轻松登录。但是,如果我在反向代理后面运行相同的代码,则oauth请求将无法正常工作。

oauth请求类似于http://test2.test.com:50489/oauth/v1/authorize?client_id=f7d1705a-b3fb-45b8-84ee-0afa4179f964&redirect_uri=https:%2F%2Ftest1.test.com%2Flogin&state=LPHxiHo_AmnfB1hqPjSNVQ&scope=Profile&response_type=code。 我想要如下所示的oauth网址, https://test2.test.com/oauth/v1/authorize?client_id=f7d1705a-b3fb-45b8-84ee-0afa4179f964&redirect_uri=https:%2F%2Ftest1.test.com%2Flogin&state=LPHxiHo_AmnfB1hqPjSNVQ&scope=Profile&response_type=code

对此有什么想法吗?

0 个答案:

没有答案