[solved]How to configure apache behind nginx?

Discussion of non-phpBB related topics with other phpBB.com users.
Forum rules
General Discussion is a bonus forum for discussion of non-phpBB related topics with other phpBB.com users. All site rules apply.
Post Reply
wdicc
Registered User
Posts: 1
Joined: Mon Aug 27, 2018 11:45 am

[solved]How to configure apache behind nginx?

Post by wdicc » Mon Aug 27, 2018 11:55 am

I have setup the forum on server A(it's ip is ip_a) use apache, I can access it use 'http://ip_a/' . I'm trying to add an nginx as a reverse proxy, use settings like below:

Code: Select all

server {
    listen          80;
    server_name     my.domain.com;
    # access_log      logs/alice.access.log main;
    access_log      off;
    error_log  /dev/stderr;
    client_max_body_size 10m;

    if ($http_x_forwarded_proto != "https") {
       rewrite ^(.*)$ https://$server_name$REQUEST_URI permanent;
    }

    location /forum {
        proxy_pass http://ip_a/;
        proxy_set_header Host      $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
And then I tried 'https://my.domain.com/forum', all css and scripts are get 404 response, and links are using 'https://my.domain.com/' as web root, I've tried to set 'Force server URL settings' to true and set 'Script path' to '/fourm', it's not work, how can I fix this?
Last edited by wdicc on Tue Aug 28, 2018 2:10 am, edited 1 time in total.

User avatar
Mick
Support Team Member
Support Team Member
Posts: 19977
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: How to configure apache behind nginx?

Post by Mick » Mon Aug 27, 2018 1:34 pm

Generally server support is beyond the scope of these forums and your issue appears related to your server configuration. We can attempt to help you, but due to the number of varying configurations we may not have the necessary expertise to help with your particular setup. You may be better off seeking help on a support site for the server/set up you’re using. Filling out the Support Request Template may help.
"The more connected we get the more alone we become" - Kyle Broflovski

There are no ‘threads’ in phpBB, they are topics.

User avatar
Lumpy Burgertushie
Registered User
Posts: 64863
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: How to configure apache behind nginx?

Post by Lumpy Burgertushie » Mon Aug 27, 2018 9:15 pm

this may just show my ignorance of the subject but I thought that nginx was a replacement for apache on the server. how can you run them both?


robert

User avatar
3Di
Registered User
Posts: 12893
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: How to configure apache behind nginx?

Post by 3Di » Mon Aug 27, 2018 9:19 pm

wdicc wrote:
Mon Aug 27, 2018 11:55 am
I'm trying to add an nginx as a reverse proxy,
https://www.digitalocean.com/community/ ... for-apache
Lumpy Burgertushie wrote:
Mon Aug 27, 2018 9:15 pm
how can you run them both?
http://kbeezie.com/apache-with-nginx/

wdicc
Registered User
Posts: 1
Joined: Mon Aug 27, 2018 11:45 am

Re: How to configure apache behind nginx?

Post by wdicc » Tue Aug 28, 2018 2:10 am

I think you all misunderstand the problem I meet. I've solved it by move all phpbb files on server A into a subdirectory 'forum', and change nginx settings to below:

Code: Select all

server {
    listen          80;
    server_name     my.domain.com;
    # access_log      logs/alice.access.log main;
    access_log      off;
    error_log  /dev/stderr;
    client_max_body_size 10m;

    if ($http_x_forwarded_proto != "https") {
       rewrite ^(.*)$ https://$server_name$REQUEST_URI permanent;
    }

    location /forum {
        proxy_pass http://ip_a/forum;
        proxy_set_header Host      $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
The solution looks some kind of ugly but it worked.

Post Reply

Return to “General Discussion”

Who is online

Users browsing this forum: Dalibor.K and 24 guests