Nginx Reverse Proxy – Proxied Page Resources Do Not Load

I have a Nginx reverse proxy setup and working, but the proxied page/service does not completely load all of the remote content. I am using the reverse proxy as a way to re-configure the user-agent of the session so that the content is served a certain way based on the way the hosted service will handle the specific access request based on the user-agent.

First issue I have found is that the only way I can get the proxy to load the content is by adding a trailing slash ‘/’ on the request… for example, assuming the proxy is hosted on 10.10.10.9, I would get the remote site to load using 10.10.10.9:83/app/. However, this has caused some odd behavior. When the remote site (proxied site) loads, all of the resources on the remote site (for example logos on the page) do not load as they are not “found.” Upon inspection through the web browser (using developer tools in Chrome), the path of the file is a relative path that would be hosted on the server of the remote service. For example the HTML may refer to /files/images/image.png but when it is read through the proxy it will show //files/images/image.png.

It is behaving almost as if the proxy is not leveraging the remote service to actually process the request. I am guessing I am doing something wrong with the configuration on the Nginx configuration file. I’d love to hear someone’s thoughts on this.

My goal is to make it so that the content on the remote service (all hosted in the same environment) can be fully loaded while passing through this proxy (in order to change user-agent).

Configuration file for the reverse proxy:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>server {
listen 83;
location / {
proxy_set_header User-Agent "Mozilla/4.0;compatible; MSIE 6.0; Windows NT 5.1, Windows Phone 6.5.3.5";
proxy_set_header Viewport "width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no";
proxy_connect_timeout 159s;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_pass_header Set-Cookie;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_ignore_headers Cache-Control Expires;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 128;
proxy_set_header Referer $http_referer;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://10.10.10.10:83/$request_uri;
}
}
</code>
<code>server { listen 83; location / { proxy_set_header User-Agent "Mozilla/4.0;compatible; MSIE 6.0; Windows NT 5.1, Windows Phone 6.5.3.5"; proxy_set_header Viewport "width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"; proxy_connect_timeout 159s; proxy_send_timeout 600; proxy_read_timeout 600; proxy_buffer_size 64k; proxy_buffers 16 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_pass_header Set-Cookie; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_ignore_headers Cache-Control Expires; proxy_headers_hash_max_size 512; proxy_headers_hash_bucket_size 128; proxy_set_header Referer $http_referer; proxy_set_header Host $host; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://10.10.10.10:83/$request_uri; } } </code>
server {
        listen 83;
        location / {
                proxy_set_header User-Agent "Mozilla/4.0;compatible; MSIE 6.0; Windows NT 5.1, Windows Phone 6.5.3.5";
                proxy_set_header Viewport "width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no";
                proxy_connect_timeout 159s;
                proxy_send_timeout 600;
                proxy_read_timeout 600;
                proxy_buffer_size 64k;
                proxy_buffers 16 32k;
                proxy_busy_buffers_size 64k;
                proxy_temp_file_write_size 64k;
                proxy_pass_header Set-Cookie;
                proxy_redirect off;
                proxy_hide_header Vary;
                proxy_set_header Accept-Encoding '';
                proxy_ignore_headers Cache-Control Expires;
                proxy_headers_hash_max_size 512;
                proxy_headers_hash_bucket_size 128;
                proxy_set_header Referer $http_referer;
                proxy_set_header Host $host;
                proxy_set_header Cookie $http_cookie;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://10.10.10.10:83/$request_uri;
        }
}

Attempted to use Nginx reverse proxy to load remote content while changing the user-agent

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật