I want to build a reverse proxy that when someone access url http://proxy.net/fwd/https://target.site.com/, he will get content of target.site.com, but is over HTTP rather than HTTPS. Of course target.site.com can be any other site.

I have a nginx.conf here but it always responds 500. What's wrong with it?

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections  1024;

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include             /etc/nginx/conf.d/*.conf;

    server {
        listen      80;
        server_name proxy.net;

        location ~ ^/fwd/(?<fwd_path>.*)$ {
            add_header Access-Control-Allow-Origin "*";
            proxy_redirect off;
            proxy_pass $fwd_path;



  • What do the extended messages in your logs say is the cause of the 500?
    – user9517
    Feb 6, 2017 at 8:07
  • /var/log/nginx/nginx_error.log is empty. Also I don't know why I get -2, this question is such terrible? Feb 6, 2017 at 8:24
  • Make your server provide the information in the logs by configuring it correctly.
    – user9517
    Feb 6, 2017 at 8:27
  • Is there something else I can do other than to place error_log /var/log/nginx/error.log; in the root scope of nginx.conf? Feb 6, 2017 at 8:32
  • Have you heard about URL-Encoding? Your $fwd_path will contain "https%3A%2F%2Ftarget.site.com%2F" which just won't work
    – Anubioz
    Feb 6, 2017 at 9:51


You must log in to answer this question.

Browse other questions tagged .