EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #09614


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Eprints with Nginx Proxy Manager as Load Balancer


CAUTION: This e-mail originated outside the University of Southampton.
I think that error message is about the max file size, i tried to upload pdf files that is lower than 125 mb and it accept the upload. 

I checked the 88_uploadmethod_file.js and it set to max file size is set at 1024.

i dont know why it is not working.

On Thu, Feb 15, 2024, 8:31 PM David R Newman <drn@ecs.soton.ac.uk> wrote:

Hi Zen,

Actually, running Ubuntu makes things easier. You have two sites enabled in Apache you can just disable the default-ssl one:

a2dissite default-ssl

Then append the following line to the end of eprints.conf (substituting EPRINTS_PATH as appropriate):

Include EPRINTS_PATH/archives/*/ssl/securevhost.conf

After doing this check and reload (probably best to restart) Apache:

apache2ctl configtest
apache2ctl restart


Regarding the error message you sent as a screenshot attachment.  I am not sure why is is reporting that the 404 error message with the /cgi/ajax/upload_progress?progressid=1A8B... requests.  Having a proxy in front of you repository makes things more complicated.  I would advise trying this both with and without the change I recommended you make to EPRINTS_PATH/lib/static/_javascript_/auto/88_uploadmethod_file.js. I think it is unlikely this change will be the reason it is not working but it a closely related difference between your repository and and default EPrints 3.4.5 installation.

Does anyone else have any suggestions (particular people who use a proxy in front of EPrints) why the upload_progress GET requests would receive 404 error messages? 

Regards

David Newman

On 15/02/2024 08:03, zen zenitram wrote:
CAUTION: This e-mail originated outside the University of Southampton.
Good day!

The apache error message has been fixed, and now i can delete some uploaded files, and i tried to upload files and it work at first then when i tried it again this error occurred.

i attached the error.

Thank you!

On Wed, Feb 14, 2024 at 6:07 PM David R Newman <drn@ecs.soton.ac.uk> wrote:

Hi Zen,

Sorry, that last line should have been:

openssl x509 -req -days 3650 -in EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.csr -signkey EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.key -out EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.crt

Also, you do not want to set challenge password when creating the key.  As Apache will not be able to provide this password when it tries to load the key.

Regards

David Newman

On 14/02/2024 09:18, zen zenitram wrote:

CAUTION: This e-mail originated outside the University of Southampton.
Hello Sir David

I tried your solution but i got stuck at creating self-signed certificate.

Here is the error

lease enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:****
An optional company name []:ers
root@edocs-001:~# openssl x509 -req -days 3650 -in cert.csr -signkey /opt/eprints3/archives/aea/ssl/thesis.dlsud.edu.ph.key -out /opt/eprints3/archives/aea/ssl/thesis.dlsud.edu.ph.crt
Can't open "cert.csr" for reading, No such file or directory
4017445ACF7F0000:error:80000002:system library:BIO_new_file:No such file or directory:../crypto/bio/bss_file.c:67:calling fopen(cert.csr, r)
4017445ACF7F0000:error:10000080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:75:
Unable to load certificate request input
root@edocs-001:~#


but when i look at ssl folder
it has the .csr file and .key file
root@edocs-001:/opt/eprints3/archives/aea/ssl# ls
thesis.dlsud.edu.ph.csr  thesis.dlsud.edu.ph.key

do i need to fix permission and ownership of the ssl directory?
Thank you!


On Tue, Feb 13, 2024 at 5:36 PM David R Newman <drn@ecs.soton.ac.uk> wrote:
Hi Zen,

The Let's Encrypt page was just an example, as bar the certificate configuration it contains all the configuration you need to enable HTTPS.  I will see if I can walk you through this:

1. Create a directory called ssl under your archive (substitute EPRINTS_PATH and ARCHIVE_ID as appropriate):

mkdir EPRINTS_PATH/archives/ARCHIVE_ID/ssl/

2. Create a self-signed certificate and key (substitute EPRINTS_PATH and ARCHIVE_ID as appropriate):

openssl genrsa -out EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.key 4096
openssl req -new -key EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.key -out EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.csr
openssl x509 -req -days 3650 -in cert.csr -signkey EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.key -out EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.crt


3. Add the following Apache configuration file under EPRINTS_PATH/archives/ARCHIVE_ID/ssl/securevhost.conf (substituting EPRINTS_PATH and ARCHIVE_ID as appropriate):

 <VirtualHost *:443>

     ServerName thesis.dlsud.edu.ph:443
 
     # Enable HSTS
     Header always set Strict-Transport-Security "max-age=63072000;"
 
     SSLEngine on
     SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
     SSLHonorCipherOrder on
     SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256

     SSLCertificateFile EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.crt
     SSLCertificateKeyFile EPRINTS_PATH/archives/ARCHIVE_ID/ssl/thesis.dlsud.edu.ph.key
 
     SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
 
     LogLevel warn
     ErrorLog logs/ssl_error_log    
     TransferLog logs/ssl_access_log
     CustomLog logs/ssl_request_log \
         "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
 
     Include EPRINTS_PATH/cfg/apache_ssl/ARCHIVE_ID.conf
 
     PerlTransHandler +EPrints::Apache::Rewrite
 
</VirtualHost>

3. Make sure this securehost.conf configuration file is included in the same Apache configuration (under /etc/httpd/ or /etc/apache2/) you edited to include EPRINTS_PATH/cfg/apache.conf.  This will require the following configuration line (substituting EPRINTS_PATH and ARCHIVE_ID as appropriate):

Include EPRINTS_PATH/archives/ARCHIVE_ID/ssl/securevhost.conf

4. Edit EPRINTS_PATH/archives/ARCHIVE_ID/cfg/cfg.d/10_core.pl so it looks as follows (assuming you only have the hostname thesis.dlsud.edu.ph):

$c->{host} = undef;
$c->{port} = 80;
$c->{aliases} = [];
$c->{securehost} = 'thesis.dlsud.edu.ph';
$c->{secureport} = 443;
$c->{http_root} = undef;

5. Test you EPrints configuration and regenerate EPrints Apache configuration with the following two commands (substitute EPRINTS_PATH as appropriate):

EPRINTS_PATH/bin/epadmin test
EPRINTS_PATH/bin/generate_apacheconf --system --replace


6.  Assuming neither of those commands generate errors, check you Apache configuration and restart Apache.  (There may be an issue with there already be a generic HTTPS host under /etc/httpd/conf.d/ssl.conf.  If so, then you need to remove the whole VirtualHost block (i.e. between <VirtualHost> and </VirtualHost> inclusive) in this file then try these two commands again).

apachectl configtest
apachectl restart


7. To make sure now HTTP URLs are still cache make sure all caches are cleared (substitute EPRINTS_PATH and ARCHIVE_ID as appropriate):

EPRINTS_PATH/bin/epadmin refresh_abstracts ARCHIVE_ID
EPRINTS_PATH/bin/epadmin refresh_views ARCHIVE_ID
EPRINTS_PATH/bin/generate_static ARCHIVE_ID

8. Once that is all done make sure your colleague responsible for the NGinX proxy is now pointing at your server on port 443 rather than 80 and expecting HTTPS rather than HTTP.

Regards

David Newman

On 13/02/2024 6:07 am, zen zenitram wrote:
CAUTION: This e-mail originated outside the University of Southampton.
Good day!

Our network admin says that i should not use Let's Encrypt on my server because the load balancer has it already, He said that it will create conflict on the load balancer.

How can i create this virtualhost without  SSLCertificateChainFile or let's encrypt?

Do i need to remove the 3 SSLCertificate (with Highlight)?

Thank you very much! 

 <VirtualHost *:443>

     ServerName YOUR-REPOSITORY-DOMAIN:443
 
     # Enable HSTS
     Header always set Strict-Transport-Security "max-age=63072000;"
 
     SSLEngine on
     SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
     SSLHonorCipherOrder on
     SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256

     SSLCertificateFile /etc/letsencrypt/live/YOUR-REPOSITORY-DOMAIN/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/YOUR-REPOSITORY-DOMAIN/privkey.pem
     SSLCertificateChainFile /etc/letsencrypt/live/YOUR-REPOSITORY-DOMAIN/chain.pem

 
     SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
 
     LogLevel warn
     ErrorLog logs/ssl_error_log    
     TransferLog logs/ssl_access_log
     CustomLog logs/ssl_request_log \
         "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
 
     Include EPRINTS_PATH/cfg/apache_ssl/REPOID.conf
 
     PerlTransHandler +EPrints::Apache::Rewrite
 
</VirtualHost>

On Mon, Feb 12, 2024 at 10:39 PM David R Newman <drn@ecs.soton.ac.uk> wrote:

Hi Zen,

This looks to be a mixed content issue.  EPrints has evolved over time from a time before HTTPS was widely available, through a time where HTTPS was needed but only for administration pages, to a time where HTTPS is almost exclusively used with HTTP requests upgraded either by the browser or by HTTP to HTTPS redirects.

I think you issue is that you have EPrints running with an HTTP-only configuration but your NGinX proxy is HTTPS. Sometimes EPrints uses full URLs, which include a protocol (i.e. HTTP or HTTPS) and this is where you mixed content warnings are arising.  In an ideal world EPrints would only use relative URLs but as content is often embedded in third-party application there is still a requirement for full URLs in certain places.  (We have experimented with protocol independent URLs, e.g. //eprints.example.org/cgi/users/login.  However, if anything this added to the complexity of different types of URL being generated, so was decided against).

Anyway, to solve your problem you want to run you EPrints repository on your server in HTTPS-only rather than HTTP-only mode by reconfiguring your archive's cfg/cfg.d/10_core.pl (see [1]).  You should only require a self-signed HTTPS certificate [2] as your NGinX proxy should be configurable to just care what the port number and protocol (i.e. HTTPS or HTTP) are.  You will also need to add an HTTPS virtualhost.  There is a good example on [3] but you will need to update the SSLCertificate... lines to point at you self-signed certificate and key (you should not need a SSLCertificateChainFile for a self-signed certificate). 

Once you have redone all this configuration and tested it.  Make sure you regenerate your Apache configuration and restart Apache and also clear any caches that may still be using HTTP URLs:

EPRINTS_PATH/bin/epadmin test
EPRINTS_PATH/bin/generate_apacheconf --system --replace
apachectl restart
EPRINTS_PATH/bin/epadmin refresh_views ARCHIVE_ID
EPRINTS_PATH/bin/epadmin refresh_abstracts ARCHIVE_ID
EPRINTS_PATH/bin/generate_static ARCHIVE_ID

Regards

David Newman

[1] https://wiki.eprints.org/w/Simplified_HTTPS_Configuration
[2] https://gist.github.com/taoyuan/39d9bc24bafc8cc45663683eae36eb1a
[3] https://wiki.eprints.org/w/Setting_up_HTTPS_using_Let%27s_Encrypt

On 12/02/2024 07:03, zen zenitram wrote:
CAUTION: This e-mail originated outside the University of Southampton.
Good day!

 still can't upload and delete files. Here is error when i tried to upload.



On Wed, Jan 31, 2024 at 9:52 PM David R Newman <drn@ecs.soton.ac.uk> wrote:

Hi Zen,

It is difficult to debug an issue when you have a proxy sitting in front of your EPrints repository with no information about how that proxy has been configured.  However, I have taken a look at the Upload stage on my EPrints test repository running the latest version of EPrints and I can see a request that is locally blocked that relates to the iframe generated by _javascript_ to provide the upload progress*.  To avoid getting this blocked request (which may be causing your error message and upload issues) I would recommend commenting out the following line from EPRINTS_PATH/lib/static/_javascript_/auto/88_uploadmethod_file.js:

hidden_iframe.setAttribute( 'src', '#' );

So that it becomes:

// hidden_iframe.setAttribute( 'src', '#' );

This is on around line 314 for 88_uploadmethod_file.js.  Once you have done this you will need to hard reload (e.g. Ctrl+Shift+R) the Upload stage of the workflow in your web browser and this should update your main _javascript_ file.  Then try uploading a file again.  If this does not work do you get  the same error message.  If you get the same error message, it is worth taking a look at https://thesis.dlsud.edu.ph/_javascript_/auto-VERSION.js (substituting VERSION for you version, e.g. 3.4.5) to make sure this line above is now commented out there.  If it is not commented out, try using a private/incognito browser window to test this to try to avoid any caching of the old _javascript_.

Regards

David Newman

*This is a very ugly way of managing upload but was needed when the uploader was first written.  We plan to completely overhaul how the uploader works for the next major version of EPrints.

On 31/01/2024 02:17, zen zenitram wrote:
CAUTION: This e-mail originated outside the University of Southampton.
CAUTION: This e-mail originated outside the University of Southampton.
Good day! 

Our eprints repository works fine with it, you can log in and search and open attached documents. The Problem occurs when we try to add new title to repository and upload pdf files. attached are the errors shows when we upload documents. 

and also when we try to delete the attached pdf file it only gives black page instead of the delete option.

Thank you!

*** Options: https://wiki.eprints.org/w/Eprints-tech_Mailing_List
*** Archive: https://www.eprints.org/tech.php/
*** EPrints community wiki: https://wiki.eprints.org/